Copy link to clipboard
Copied
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body><cfset currentPath = getCurrentTemplatePath()>
<cfset currentDirectory = getDirectoryFromPath(currentPath)><cfscript>
function udf_Translate(Name, Filename, Section) {
var outText="";// If user selected default language (English), bypass the translation
if (cookie.cookie_language eq "EN")
return Name;
if (Filename eq "")
Filename = "Common";
if (Section eq "")
Section = "Common";
INI_Path = #currentDirectory# & "Language.properties";
outText = GetProfileString(INI_Path, Section, Name);
return IIf(Len(Trim(outText)) gt 0, DE(outText), DE(Name));
}
</cfscript><cfoutput>#udf_translate("Ward", "Inpatient", "")#</cfoutput>
</body>
</html>
Language.properties
[COMMON]
Ward=Phường
It output only "Ward" instead of Phường when I save this file as UFT-8. But, when I save this file as ANSI encoding, it output as Phu?ng. It's wrong. Why GetProfileString doesn't UTF-8 format? Any solutions will be appreciated.
Copy link to clipboard
Copied
no it doesn't support unicode. and probably not a good idea to use it for
resource bundle (RB) substitute, use real RB instead.
http://www.sustainablegis.com/unicode/resourceBundle/rb.cfm
Copy link to clipboard
Copied
Thanks, it's cool. But, is there any others solution for reading unicode format in Language.properties with GetProfileString?
Copy link to clipboard
Copied
no.
Copy link to clipboard
Copied
I've created it by myself. Here you go :
http://ppshein.wordpress.com/2009/12/04/internationalized-in-cfmx/
Copy link to clipboard
Copied
no, i believe that's called re-inventing the wheel.
Copy link to clipboard
Copied
ha ha... you can say that again. But, I can do it by myself.
Copy link to clipboard
Copied
you didn't need to (that's why it's called "re-inventing the wheel"):
http://www.sustainablegis.com/blog/cfg11n/index.cfm?mode=cat&catid=6D990B76-50FC-543B-1FA4AB2B1CE26EFC
once these things get bigger & more complex, how will you manage them? notepad?
you're better off sticking w/a "main stream"/proven methodology that are based
on good practices than knocking off stuff like this.
Copy link to clipboard
Copied
ahh.. nope, thanks anyway. Because, we use "getprofilestring" for internationalize in our project. In our projects, there are more than 500 files. Now, our client is Vietnamense and their language is created by unicode. As you know, getprofilestring doesn't support unicode. That's why I create it above coding, and don't wanna touch all files in our projects for this language. If we use above link you show, we need to replace all files.
Copy link to clipboard
Copied
what you're doing is a perfect example of a bad practice. i guess that you
didn't bother researching this before you started. suit yourself.
Copy link to clipboard
Copied
Sure, dude. Because, we're on rush. Thanks, anyway.
Copy link to clipboard
Copied
This exchange is quite familiar. It occurs daily at our own neck of the woods. What fun!