Localisation

From Portal Corps
Jump to navigation Jump to search

There appear to be two bin files that control localisation of pstrings

data/bin/clientmessages-en.bin
data/server/bin/messages-en.bin

Once

\libs\UtilitiesLib\language\AppLocale.c

has been modified to stop forcing english mode, the client can be put into german or french as desired.

cityofheroes.exe -setlocale 1036
data/bin/clientmessages-fr.bin
data/server/bin/messages-fr.bin
cityofheroes.exe -setlocale 1031
data/bin/clientmessages-de.bin
data/server/bin/messages-de.bin

There is technically support for:

1337 -test (Test)
1028 -zh (Chinese Traditional)
1042 -ko (Korean)
1041 -jp (Japanese)
1034 -es (Spanish)

But these are flagged as not implemented. They might need extra work, or it might just be a case of adding the bin files and enabling them. Similarly we can probably add new languages to the table.


This is my current diff, once i've done testing on the server side i'll make a proper branch and pull request with full implementation details.

diff --git "a/libs/UtilitiesLib/language/AppLocale.c" "b/libs/UtilitiesLib/language/AppLocale.c"
index ca734425..c179d046 100644
--- "a/libs/UtilitiesLib/language/AppLocale.c"
+++ "b/libs/UtilitiesLib/language/AppLocale.c"
@@ -144,8 +144,7 @@ int locGetMaxLocaleCount(void){
 
 int locIDIsValid(int localeID)
 {
-	devassertmsg(localeID == -1 || localeID == LOCALE_ID_ENGLISH, "Locale is not being set to english properly.");
-	return localeID == LOCALE_ID_ENGLISH;
+	return localeID >= 0 && localeID < locGetMaxLocaleCount() && LocaleTable[localeID].isImplemented;
 }
 
 int locIDIsValidForPlayers(int localeID)
@@ -164,11 +163,20 @@ void locOverrideIDInRegistryForServersOnly(int localeID)
 }
 
 int locGetIDInRegistry(void){
-	return LOCALE_ID_ENGLISH;
+	RegReader reader;
+	int tempLocale = LOCALE_ENGLISH;
+
+	reader = createRegReader();
+	initRegReader(reader, regGetAppKey());
+	rrReadInt(reader, "Locale", &tempLocale);
+	destroyRegReader(reader);
+	printf("locGetIDINRegistry returned %d\n", tempLocale);
+	return tempLocale;
 }
 
 void locSetIDInRegistry(int localeID){
 	RegReader reader;
+	printf("locSetIDINRegistry called with %d\n", localeID);
 
 	// Get the locale setting from the registry.
 	reader = createRegReader();
@@ -179,12 +187,12 @@ void locSetIDInRegistry(int localeID){
 
 int getCurrentLocale(void)
 {
-	return LOCALE_ID_ENGLISH;
+	return currentLocale;
 }
 
 void setCurrentLocale(int locale){
 	
-	locale = LOCALE_ID_ENGLISH;
+	currentLocale = locale;
 }
 
 int getCurrentRegion(void)