From 47c824959d84e009674654f11da2f17e426a67a6 Mon Sep 17 00:00:00 2001 From: "valeski%netscape.com" Date: Thu, 18 May 2000 21:52:23 +0000 Subject: [PATCH] 38695. r=alecf. i18n network error strings git-svn-id: svn://10.0.0.236/trunk@70474 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/docshell/base/appstrings.properties | 8 ++--- mozilla/docshell/base/nsDocShell.cpp | 11 +++--- mozilla/docshell/base/nsWebShell.cpp | 40 ++++++++++----------- mozilla/webshell/src/nsWebShell.cpp | 40 ++++++++++----------- 4 files changed, 51 insertions(+), 48 deletions(-) diff --git a/mozilla/docshell/base/appstrings.properties b/mozilla/docshell/base/appstrings.properties index b5338584715..fec29fb7413 100644 --- a/mozilla/docshell/base/appstrings.properties +++ b/mozilla/docshell/base/appstrings.properties @@ -17,7 +17,7 @@ # # Contributor(s): -dnsNotFound=could not be found. Please check the name and try again. -protocolNotFound=is not a registered protocol. -connectionFailure=The connection was refused when attempting to contact -netTimeout=The operation timed out when attempting to contact +dnsNotFound=%s could not be found. Please check the name and try again. +protocolNotFound=%s is not a registered protocol. +connectionFailure=The connection was refused when attempting to contact %s. +netTimeout=The operation timed out when attempting to contact %s. diff --git a/mozilla/docshell/base/nsDocShell.cpp b/mozilla/docshell/base/nsDocShell.cpp index 963cda3bf8e..186453d70c1 100644 --- a/mozilla/docshell/base/nsDocShell.cpp +++ b/mozilla/docshell/base/nsDocShell.cpp @@ -41,6 +41,7 @@ #include "nsPoint.h" #include "nsGfxCIID.h" #include "nsIPrompt.h" +#include "nsTextFormatter.h" // Local Includes #include "nsDocShell.h" @@ -1040,12 +1041,14 @@ NS_IMETHODIMP nsDocShell::LoadURI(const PRUnichar* aURI) // extract the scheme nsAutoString scheme; uriString.Left(scheme, colon); + nsCAutoString cScheme; + cScheme.AssignWithConversion(scheme); - nsAutoString dnsMsg(scheme); - dnsMsg.AppendWithConversion(' '); - dnsMsg.Append(messageStr); + PRUnichar *msg = nsTextFormatter::smprintf(messageStr, cScheme.GetBuffer()); + if (!msg) return NS_ERROR_OUT_OF_MEMORY; - prompter->Alert(nsnull, dnsMsg.GetUnicode()); + prompter->Alert(nsnull, msg); + nsTextFormatter::smprintf_free(msg); } // end unknown protocol if(!uri) diff --git a/mozilla/docshell/base/nsWebShell.cpp b/mozilla/docshell/base/nsWebShell.cpp index d8a335ba74a..2961d5faacf 100644 --- a/mozilla/docshell/base/nsWebShell.cpp +++ b/mozilla/docshell/base/nsWebShell.cpp @@ -95,6 +95,7 @@ typedef unsigned long HMTX; #include "nsICharsetConverterManager.h" #include "nsISocketTransportService.h" #include "nsILayoutHistoryState.h" +#include "nsTextFormatter.h" #include "nsIHTTPChannel.h" // add this to the ick include list...we need it to QI for post data interface #include "nsHTTPEnums.h" @@ -1189,7 +1190,6 @@ nsWebShell::OnEndDocumentLoad(nsIDocumentLoader* loader, if(mDocLoader == loader && NS_FAILED(aStatus)) { - nsAutoString errorMsg; nsXPIDLCString host; NS_ENSURE_SUCCESS(aURL->GetHost(getter_Copies(host)), NS_ERROR_FAILURE); @@ -1270,11 +1270,11 @@ nsWebShell::OnEndDocumentLoad(nsIDocumentLoader* loader, NS_ConvertASCIItoUCS2("dnsNotFound").GetUnicode(), getter_Copies(messageStr)), NS_ERROR_FAILURE); - errorMsg.AssignWithConversion(host); - errorMsg.AppendWithConversion(' '); - errorMsg.Append(messageStr); + PRUnichar *msg = nsTextFormatter::smprintf(messageStr, (const char*)host); + if (!msg) return NS_ERROR_OUT_OF_MEMORY; - prompter->Alert(nsnull, errorMsg.GetUnicode()); + prompter->Alert(nsnull, msg); + nsTextFormatter::smprintf_free(msg); } else if(aStatus == NS_ERROR_CONNECTION_REFUSED) {// Doc failed to load because we couldn't connect to the server. @@ -1293,16 +1293,17 @@ nsWebShell::OnEndDocumentLoad(nsIDocumentLoader* loader, NS_ConvertASCIItoUCS2("connectionFailure").GetUnicode(), getter_Copies(messageStr)), NS_ERROR_FAILURE); - errorMsg.Assign(messageStr); - errorMsg.AppendWithConversion(' '); - errorMsg.AppendWithConversion(host); - if(port > 0) - { - errorMsg.AppendWithConversion(':'); - errorMsg.AppendInt(port); - } - errorMsg.AppendWithConversion('.'); - prompter->Alert(nsnull, errorMsg.GetUnicode()); + // build up the host:port string. + nsCAutoString combo(host); + if (port > 0) { + combo.Append(':'); + combo.AppendInt(port); + } + PRUnichar *msg = nsTextFormatter::smprintf(messageStr, combo.GetBuffer()); + if (!msg) return NS_ERROR_OUT_OF_MEMORY; + + prompter->Alert(nsnull, msg); + nsTextFormatter::smprintf_free(msg); } else if(aStatus == NS_ERROR_NET_TIMEOUT) {// Doc failed to load because the socket function timed out. @@ -1319,12 +1320,11 @@ nsWebShell::OnEndDocumentLoad(nsIDocumentLoader* loader, NS_ConvertASCIItoUCS2("netTimeout").GetUnicode(), getter_Copies(messageStr)), NS_ERROR_FAILURE); - errorMsg.Assign(messageStr); - errorMsg.AppendWithConversion(' '); - errorMsg.AppendWithConversion(host); - errorMsg.AppendWithConversion('.'); + PRUnichar *msg = nsTextFormatter::smprintf(messageStr, (const char*)host); + if (!msg) return NS_ERROR_OUT_OF_MEMORY; - prompter->Alert(nsnull, errorMsg.GetUnicode()); + prompter->Alert(nsnull, msg); + nsTextFormatter::smprintf_free(msg); } // end NS_ERROR_NET_TIMEOUT } // end mDocLoader == loader diff --git a/mozilla/webshell/src/nsWebShell.cpp b/mozilla/webshell/src/nsWebShell.cpp index d8a335ba74a..2961d5faacf 100644 --- a/mozilla/webshell/src/nsWebShell.cpp +++ b/mozilla/webshell/src/nsWebShell.cpp @@ -95,6 +95,7 @@ typedef unsigned long HMTX; #include "nsICharsetConverterManager.h" #include "nsISocketTransportService.h" #include "nsILayoutHistoryState.h" +#include "nsTextFormatter.h" #include "nsIHTTPChannel.h" // add this to the ick include list...we need it to QI for post data interface #include "nsHTTPEnums.h" @@ -1189,7 +1190,6 @@ nsWebShell::OnEndDocumentLoad(nsIDocumentLoader* loader, if(mDocLoader == loader && NS_FAILED(aStatus)) { - nsAutoString errorMsg; nsXPIDLCString host; NS_ENSURE_SUCCESS(aURL->GetHost(getter_Copies(host)), NS_ERROR_FAILURE); @@ -1270,11 +1270,11 @@ nsWebShell::OnEndDocumentLoad(nsIDocumentLoader* loader, NS_ConvertASCIItoUCS2("dnsNotFound").GetUnicode(), getter_Copies(messageStr)), NS_ERROR_FAILURE); - errorMsg.AssignWithConversion(host); - errorMsg.AppendWithConversion(' '); - errorMsg.Append(messageStr); + PRUnichar *msg = nsTextFormatter::smprintf(messageStr, (const char*)host); + if (!msg) return NS_ERROR_OUT_OF_MEMORY; - prompter->Alert(nsnull, errorMsg.GetUnicode()); + prompter->Alert(nsnull, msg); + nsTextFormatter::smprintf_free(msg); } else if(aStatus == NS_ERROR_CONNECTION_REFUSED) {// Doc failed to load because we couldn't connect to the server. @@ -1293,16 +1293,17 @@ nsWebShell::OnEndDocumentLoad(nsIDocumentLoader* loader, NS_ConvertASCIItoUCS2("connectionFailure").GetUnicode(), getter_Copies(messageStr)), NS_ERROR_FAILURE); - errorMsg.Assign(messageStr); - errorMsg.AppendWithConversion(' '); - errorMsg.AppendWithConversion(host); - if(port > 0) - { - errorMsg.AppendWithConversion(':'); - errorMsg.AppendInt(port); - } - errorMsg.AppendWithConversion('.'); - prompter->Alert(nsnull, errorMsg.GetUnicode()); + // build up the host:port string. + nsCAutoString combo(host); + if (port > 0) { + combo.Append(':'); + combo.AppendInt(port); + } + PRUnichar *msg = nsTextFormatter::smprintf(messageStr, combo.GetBuffer()); + if (!msg) return NS_ERROR_OUT_OF_MEMORY; + + prompter->Alert(nsnull, msg); + nsTextFormatter::smprintf_free(msg); } else if(aStatus == NS_ERROR_NET_TIMEOUT) {// Doc failed to load because the socket function timed out. @@ -1319,12 +1320,11 @@ nsWebShell::OnEndDocumentLoad(nsIDocumentLoader* loader, NS_ConvertASCIItoUCS2("netTimeout").GetUnicode(), getter_Copies(messageStr)), NS_ERROR_FAILURE); - errorMsg.Assign(messageStr); - errorMsg.AppendWithConversion(' '); - errorMsg.AppendWithConversion(host); - errorMsg.AppendWithConversion('.'); + PRUnichar *msg = nsTextFormatter::smprintf(messageStr, (const char*)host); + if (!msg) return NS_ERROR_OUT_OF_MEMORY; - prompter->Alert(nsnull, errorMsg.GetUnicode()); + prompter->Alert(nsnull, msg); + nsTextFormatter::smprintf_free(msg); } // end NS_ERROR_NET_TIMEOUT } // end mDocLoader == loader