X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/63986ba653aa30be8bde24c21feabb8fc6067d03..9a7fc42588474dd48660e94ca700f165ddfcd02b:/misc/languages/genlang.py diff --git a/misc/languages/genlang.py b/misc/languages/genlang.py index 99dd403416..878dfd37da 100755 --- a/misc/languages/genlang.py +++ b/misc/languages/genlang.py @@ -12,7 +12,7 @@ def ReadTable(): f = open('langtabl.txt') for i in f.readlines(): ispl = i.split() - table.append((ispl[0], ispl[1], ispl[2], ispl[3], string.join(ispl[4:]))) + table.append((ispl[0], ispl[1], ispl[2], ispl[3], ispl[4], string.join(ispl[5:]))) f.close() return table @@ -20,6 +20,9 @@ def ReadTable(): def GenEnum(table): f = open('_wxlang.h', 'wt') f.write(""" + +// --- --- --- generated code begins here --- --- --- + // This enum is generated by misc/languages/genlang.py // When making changes, please put them into misc/languages/langtabl.txt enum wxLanguage @@ -30,12 +33,18 @@ enum wxLanguage wxLANGUAGE_UNKNOWN, """); + knownLangs = [] for i in table: - f.write(' %s,\n' % i[0]) + if i[0] not in knownLangs: + f.write(' %s,\n' % i[0]) + knownLangs.append(i[0]) f.write(""" // for custom, user-defined languages: wxLANGUAGE_USER_DEFINED }; + +// --- --- --- generated code ends here --- --- --- + """) f.close() @@ -43,18 +52,25 @@ enum wxLanguage def GenDocs(table): f = open('_wxlang.tex', 'wt') f.write(""" + +%% --- --- --- generated code begins here --- --- --- + %% This enum is generated by misc/languages/genlang.py %% When making changes, please put them into misc/languages/langtabl.txt -\\begin{itemize}\\itemsep=0pt -\\item wxLANGUAGE_DEFAULT -- user's default language as obtained from the operating system -\\item wxLANGUAGE_UNKNOWN -- returned by \\helpref{GetSystemLanguage}{wxlocalegetsystemlanguage} -if it fails to detect the default language -\\item wxLANGUAGE_USER_DEFINED -- user defined languages' integer identifiers should start from -this +\\begin{twocollist}\\itemsep=0pt +\\twocolitem{wxLANGUAGE\\_DEFAULT}{user's default language as obtained from the operating system} +\\twocolitem{wxLANGUAGE\\_UNKNOWN}{returned by \\helpref{GetSystemLanguage}{wxlocalegetsystemlanguage} if it fails to detect the default language} +\\twocolitem{wxLANGUAGE\\_USER\\_DEFINED}{user defined languages' integer identifiers should start from this} """); + knownLangs = [] for i in table: - f.write('\\item %s\n' % (i[0].replace('_','\\_'))) - f.write("""\\end{itemize} + if i[0] not in knownLangs: + f.write('\\twocolitem{%s}{}\n' % (i[0].replace('_','\\_'))) + knownLangs.append(i[0]) + f.write("""\\end{twocollist}\itemsep=0pt + +%% --- --- --- generated code ends here --- --- --- + """) f.close() @@ -75,8 +91,14 @@ def GenTable(table): if ilang == '-': ilang = '0' isublang = i[3] if isublang == '-': isublang = '0' - lngtable += ' LNG(%-38s %-7s, %-15s, %-34s, %s)\n' % \ - ((i[0]+','), ican, ilang, isublang, i[4]) + if (i[4] == "LTR") : + ilayout = "wxLayout_LeftToRight" + elif (i[4] == "RTL"): + ilayout = "wxLayout_RightToLeft" + else: + print "ERROR: Invalid value for the layout direction"; + lngtable += ' LNG(%-38s %-7s, %-15s, %-34s, %s, %s)\n' % \ + ((i[0]+','), ican, ilang, isublang, ilayout, i[5]) if ilang not in all_langs: all_langs.append(ilang) if isublang not in all_sublangs: all_sublangs.append(isublang) @@ -89,10 +111,12 @@ def GenTable(table): f = open('_wxlang.cpp', 'wt') f.write(""" +// --- --- --- generated code begins here --- --- --- + // This table is generated by misc/languages/genlang.py // When making changes, please put them into misc/languages/langtabl.txt -#ifndef __WIN32__ +#if !defined(__WIN32__) || defined(__WXMICROWIN__) #define SETWINLANG(info,lang,sublang) @@ -105,10 +129,11 @@ def GenTable(table): #endif // __WIN32__ -#define LNG(wxlang, canonical, winlang, winsublang, desc) \\ +#define LNG(wxlang, canonical, winlang, winsublang, layout, desc) \\ info.Language = wxlang; \\ info.CanonicalName = wxT(canonical); \\ - info.Description = desc; \\ + info.LayoutDirection = layout; \\ + info.Description = wxT(desc); \\ SETWINLANG(info, winlang, winsublang) \\ AddLanguage(info); @@ -117,9 +142,12 @@ void wxLocale::InitLanguagesDB() wxLanguageInfo info; wxStringTokenizer tkn; - %s -}; +%s +} #undef LNG + +// --- --- --- generated code ends here --- --- --- + """ % (ifdefs, lngtable)) f.close()