diff --git a/mozilla/content/html/document/src/nsImageDocument.cpp b/mozilla/content/html/document/src/nsImageDocument.cpp
index 49a9f9d4449..4e4a62c4d67 100644
--- a/mozilla/content/html/document/src/nsImageDocument.cpp
+++ b/mozilla/content/html/document/src/nsImageDocument.cpp
@@ -37,6 +37,14 @@
#include "nsIChannel.h"
#include "nsINameSpaceManager.h"
#include "nsINodeInfo.h"
+// Needed for Localization
+#include "nsXPIDLString.h"
+#include "nsIStringBundle.h"
+
+#define NSIMAGEDOCUMENT_PROPERTIES_URI "chrome://communicator/locale/layout/ImageDocument.properties"
+static NS_DEFINE_CID(kStringBundleServiceCID, NS_STRINGBUNDLESERVICE_CID);
+
+// done L10N
// XXX TODO:
@@ -371,8 +379,6 @@ nsImageDocument::EndLayout(nsISupports *ctxt,
// and it updates the titlebar
nsresult nsImageDocument::UpdateTitle( void )
{
- nsString titleStr;
-
#ifdef USE_EXTENSION_FOR_TYPE
// XXX TEMPORARY XXX
// We want to display the image type, however there is no way to right now
@@ -393,22 +399,40 @@ nsresult nsImageDocument::UpdateTitle( void )
NS_IF_RELEASE(pURL);
}
#endif
-
- // append the image information...
- titleStr.AppendWithConversion( " Image" );
- if (mImageRequest) {
- PRUint32 width, height;
- mImageRequest->GetNaturalDimensions(&width, &height);
- // if we got a valid size (sometimes we do not) then display it
- if (width != 0 && height != 0){
- titleStr.AppendWithConversion( " " );
- titleStr.AppendInt((PRInt32)width);
- titleStr.AppendWithConversion("x");
- titleStr.AppendInt((PRInt32)height);
- titleStr.AppendWithConversion(" pixels");
+
+ nsCOMPtr bundle;
+ nsresult rv;
+ // Create a bundle for the localization
+ NS_WITH_SERVICE(nsIStringBundleService, stringService, kStringBundleServiceCID, &rv);
+ if (NS_SUCCEEDED(rv) && stringService) {
+ nsCOMPtr locale = nsnull;
+ rv = stringService->CreateBundle(NSIMAGEDOCUMENT_PROPERTIES_URI, locale, getter_AddRefs(bundle));
+ }
+ if (NS_SUCCEEDED(rv) && bundle) {
+ nsAutoString key;
+ nsXPIDLString valUni;
+ if (mImageRequest) {
+ PRUint32 width, height;
+ mImageRequest->GetNaturalDimensions(&width, &height);
+ // if we got a valid size (sometimes we do not) then display it
+ if (width != 0 && height != 0){
+ key.AssignWithConversion("ImageTitleWithDimensions");
+ nsAutoString widthStr; widthStr.AppendInt(width);
+ nsAutoString heightStr; heightStr.AppendInt(height);
+ const PRUnichar *formatStrings[2] = {widthStr.GetUnicode(), heightStr.GetUnicode()};
+ rv = bundle->FormatStringFromName(key.GetUnicode(), formatStrings, 2, getter_Copies(valUni));
+ }
}
- }
- // set it on the document
- SetTitle(titleStr);
+ if (nsLiteralString(valUni).IsEmpty()) {
+ key.AssignWithConversion("ImageTitleWithoutDimensions");
+ rv = bundle->GetStringFromName(key.GetUnicode(), getter_Copies(valUni));
+ }
+ if (NS_SUCCEEDED(rv) && valUni) {
+ nsString titleStr;
+ titleStr.Assign(valUni);
+ // set it on the document
+ SetTitle(titleStr);
+ }
+ }
return NS_OK;
}
diff --git a/mozilla/layout/html/document/src/nsImageDocument.cpp b/mozilla/layout/html/document/src/nsImageDocument.cpp
index 49a9f9d4449..4e4a62c4d67 100644
--- a/mozilla/layout/html/document/src/nsImageDocument.cpp
+++ b/mozilla/layout/html/document/src/nsImageDocument.cpp
@@ -37,6 +37,14 @@
#include "nsIChannel.h"
#include "nsINameSpaceManager.h"
#include "nsINodeInfo.h"
+// Needed for Localization
+#include "nsXPIDLString.h"
+#include "nsIStringBundle.h"
+
+#define NSIMAGEDOCUMENT_PROPERTIES_URI "chrome://communicator/locale/layout/ImageDocument.properties"
+static NS_DEFINE_CID(kStringBundleServiceCID, NS_STRINGBUNDLESERVICE_CID);
+
+// done L10N
// XXX TODO:
@@ -371,8 +379,6 @@ nsImageDocument::EndLayout(nsISupports *ctxt,
// and it updates the titlebar
nsresult nsImageDocument::UpdateTitle( void )
{
- nsString titleStr;
-
#ifdef USE_EXTENSION_FOR_TYPE
// XXX TEMPORARY XXX
// We want to display the image type, however there is no way to right now
@@ -393,22 +399,40 @@ nsresult nsImageDocument::UpdateTitle( void )
NS_IF_RELEASE(pURL);
}
#endif
-
- // append the image information...
- titleStr.AppendWithConversion( " Image" );
- if (mImageRequest) {
- PRUint32 width, height;
- mImageRequest->GetNaturalDimensions(&width, &height);
- // if we got a valid size (sometimes we do not) then display it
- if (width != 0 && height != 0){
- titleStr.AppendWithConversion( " " );
- titleStr.AppendInt((PRInt32)width);
- titleStr.AppendWithConversion("x");
- titleStr.AppendInt((PRInt32)height);
- titleStr.AppendWithConversion(" pixels");
+
+ nsCOMPtr bundle;
+ nsresult rv;
+ // Create a bundle for the localization
+ NS_WITH_SERVICE(nsIStringBundleService, stringService, kStringBundleServiceCID, &rv);
+ if (NS_SUCCEEDED(rv) && stringService) {
+ nsCOMPtr locale = nsnull;
+ rv = stringService->CreateBundle(NSIMAGEDOCUMENT_PROPERTIES_URI, locale, getter_AddRefs(bundle));
+ }
+ if (NS_SUCCEEDED(rv) && bundle) {
+ nsAutoString key;
+ nsXPIDLString valUni;
+ if (mImageRequest) {
+ PRUint32 width, height;
+ mImageRequest->GetNaturalDimensions(&width, &height);
+ // if we got a valid size (sometimes we do not) then display it
+ if (width != 0 && height != 0){
+ key.AssignWithConversion("ImageTitleWithDimensions");
+ nsAutoString widthStr; widthStr.AppendInt(width);
+ nsAutoString heightStr; heightStr.AppendInt(height);
+ const PRUnichar *formatStrings[2] = {widthStr.GetUnicode(), heightStr.GetUnicode()};
+ rv = bundle->FormatStringFromName(key.GetUnicode(), formatStrings, 2, getter_Copies(valUni));
+ }
}
- }
- // set it on the document
- SetTitle(titleStr);
+ if (nsLiteralString(valUni).IsEmpty()) {
+ key.AssignWithConversion("ImageTitleWithoutDimensions");
+ rv = bundle->GetStringFromName(key.GetUnicode(), getter_Copies(valUni));
+ }
+ if (NS_SUCCEEDED(rv) && valUni) {
+ nsString titleStr;
+ titleStr.Assign(valUni);
+ // set it on the document
+ SetTitle(titleStr);
+ }
+ }
return NS_OK;
}
diff --git a/mozilla/layout/html/forms/src/ImageDocument.properties b/mozilla/layout/html/forms/src/ImageDocument.properties
index e69de29bb2d..589b61d3fca 100644
--- a/mozilla/layout/html/forms/src/ImageDocument.properties
+++ b/mozilla/layout/html/forms/src/ImageDocument.properties
@@ -0,0 +1,23 @@
+# The contents of this file are subject to the Netscape Public
+# License Version 1.1 (the "License"); you may not use this file
+# except in compliance with the License. You may obtain a copy of
+# the License at http://www.mozilla.org/NPL/
+#
+# Software distributed under the License is distributed on an "AS
+# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
+# implied. See the License for the specific language governing
+# rights and limitations under the License.
+#
+# The Original Code is mozilla.org code.
+#
+# The Initial Developer of the Original Code is Netscape
+# Communications Corporation. Portions created by Netscape are
+# Copyright (C) 1998 Netscape Communications Corporation. All
+# Rights Reserved.
+#
+# Contributor(s):
+# Blake Ross (Original Author)
+
+#LOCALIZATION NOTE (ImageTitleWithDimensions): first %S is width, second %S is height
+ImageTitleWithDimensions=Image %Sx%S pixels
+ImageTitleWithoutDimensions=Image
diff --git a/mozilla/layout/html/forms/src/MANIFEST_PROPERTIES b/mozilla/layout/html/forms/src/MANIFEST_PROPERTIES
index 864c402a7f3..70a42c47e80 100644
--- a/mozilla/layout/html/forms/src/MANIFEST_PROPERTIES
+++ b/mozilla/layout/html/forms/src/MANIFEST_PROPERTIES
@@ -1 +1,2 @@
HtmlForm.properties
+ImageDocument.properties
diff --git a/mozilla/layout/html/forms/src/Makefile.in b/mozilla/layout/html/forms/src/Makefile.in
index dfd5df17d05..35eb1c95835 100644
--- a/mozilla/layout/html/forms/src/Makefile.in
+++ b/mozilla/layout/html/forms/src/Makefile.in
@@ -63,6 +63,7 @@ override NO_STATIC_LIB=
CHROME_DIR = locales/en-US
CHROME_L10N_DIR = communicator/locale/layout
CHROME_L10N = ./HtmlForm.properties
+CHROME_L10N = ./ImageDocument.properties
include $(topsrcdir)/config/rules.mk
diff --git a/mozilla/layout/html/forms/src/jar.mn b/mozilla/layout/html/forms/src/jar.mn
index 3706a3d0afb..0e43b270805 100644
--- a/mozilla/layout/html/forms/src/jar.mn
+++ b/mozilla/layout/html/forms/src/jar.mn
@@ -1,3 +1,5 @@
en-US.jar:
- locale/en-US/communicator/layout/HtmlForm.properties
+ locale/en-US/communicator/layout/HtmlForm.properties
+ locale/en-US/communicator/layout/ImageDocument.properties
+
diff --git a/mozilla/layout/html/forms/src/makefile.win b/mozilla/layout/html/forms/src/makefile.win
index 2d80357af8d..70970e73d3d 100644
--- a/mozilla/layout/html/forms/src/makefile.win
+++ b/mozilla/layout/html/forms/src/makefile.win
@@ -92,6 +92,7 @@ LCFLAGS = \
CHROME_DIR = locales\en-US
CHROME_L10N_DIR = communicator\locale\layout
CHROME_L10N = .\HtmlForm.properties
+CHROME_L10N = .\ImageDocument.properties
include <$(DEPTH)\config\rules.mak>