If I continue to add 7 more languages, I have to retype these repetitive commands, I will probably die.
And the characters are not displayed correctly ( like Chinese language appears in the message box. I'm still using UTF-8 encoding text ).
I have heard about using MAP, or LIST, but I have absolutely no experience for this.
How do I optimize the repetition of language strings?.
Thank you for support.
Code: Select all
#NN_EN = "English"
#NN_CN = "Chinese"
#NN_VN = "Tiếng Việt"
Structure struc_LANG
lang_path.s
hello.s
goodbye.s
EndStructure
Global *Lng.struc_LANG = AllocateStructure(struc_LANG)
*Lng\lang_path = GetCurrentDirectory() + "langs.txt"
Procedure create_lang_file()
If CreatePreferences(*Lng\lang_path)
PreferenceGroup(#NN_VN)
WritePreferenceString("hello", "Chào bạn")
WritePreferenceString("goodbye", "Tạm biệt bạn nhé")
PreferenceGroup(#NN_EN)
WritePreferenceString("hello", "Hello sir")
WritePreferenceString("goodbye", "Bye bye sir")
PreferenceGroup(#NN_CN)
WritePreferenceString("hello", "嗨,伙计")
WritePreferenceString("goodbye", "再见")
ClosePreferences()
EndIf
EndProcedure
create_lang_file()
Procedure load_VN_lang()
OpenPreferences(*Lng\lang_path)
PreferenceGroup(#NN_VN)
*Lng\hello = ReadPreferenceString("hello", "0")
*Lng\goodbye = ReadPreferenceString("goodbye", "0")
ClosePreferences()
FreeStructure(*Lng)
EndProcedure
Procedure load_EN_lang()
OpenPreferences(*Lng\lang_path)
PreferenceGroup(#NN_EN)
*Lng\hello = ReadPreferenceString("hello", "0")
*Lng\goodbye = ReadPreferenceString("goodbye", "0")
ClosePreferences()
FreeStructure(*Lng)
EndProcedure
Procedure load_CN_lang()
OpenPreferences(*Lng\lang_path)
PreferenceGroup(#NN_CN)
*Lng\hello = ReadPreferenceString("hello", "0")
*Lng\goodbye = ReadPreferenceString("goodbye", "0")
ClosePreferences()
FreeStructure(*Lng)
EndProcedure
load_CN_lang()
Debug *Lng\hello
Debug *Lng\goodbye
MessageRequester(#NN_CN, *Lng\goodbye)

