1
0
mirror of https://github.com/cookiengineer/audacity synced 2026-01-12 15:45:54 +01:00

Rewrite "Interface preferences displays self-names of languages" ...

See original attempt at commit 7ec5fd79df

This eliminates the need for a resource file at run-time.

locale/LanguageNames.txt is intended as a "source file" that is infrequently
changed as the set of supported languages changes.

The intermediate step, of appropriately copying that file into the C++ source
code in src/Languages.cpp, was done by hand.

In XCode, I set locale/LanguagesNames.txt and src/Languages.cpp to be
interpreted as Western encoding, and then the copy-paste was easy in the
editor.

The resulting C++ source code file now has string literals that are not 7-bit
ASCII.
This commit is contained in:
Paul Licameli
2018-01-02 16:10:35 -05:00
parent 1b19ab4f02
commit a1530c36a8
6 changed files with 126 additions and 77 deletions

View File

@@ -5,7 +5,7 @@ ACLOCAL_AMFLAGS = -I m4
bin_PROGRAMS = audacity$(EXEEXT) bin_PROGRAMS = audacity$(EXEEXT)
dist_doc_DATA = LICENSE.txt README.txt dist_doc_DATA = LICENSE.txt README.txt
dist_pkgdata_DATA = presets/EQDefaultCurves.xml locale/LanguageNames.txt dist_pkgdata_DATA = presets/EQDefaultCurves.xml
nobase_dist_pkgdata_DATA = \ nobase_dist_pkgdata_DATA = \
include/audacity/ConfigInterface.h \ include/audacity/ConfigInterface.h \

View File

@@ -513,7 +513,7 @@ SUBDIRS = help images lib-src po src tests
ACLOCAL_AMFLAGS = -I m4 ACLOCAL_AMFLAGS = -I m4
bin_PROGRAMS = audacity$(EXEEXT) bin_PROGRAMS = audacity$(EXEEXT)
dist_doc_DATA = LICENSE.txt README.txt dist_doc_DATA = LICENSE.txt README.txt
dist_pkgdata_DATA = presets/EQDefaultCurves.xml locale/LanguageNames.txt dist_pkgdata_DATA = presets/EQDefaultCurves.xml
nobase_dist_pkgdata_DATA = \ nobase_dist_pkgdata_DATA = \
include/audacity/ConfigInterface.h \ include/audacity/ConfigInterface.h \
include/audacity/EffectAutomationParameters.h \ include/audacity/EffectAutomationParameters.h \

View File

@@ -1,56 +1,59 @@
af Afrikaans // To edit this file, open as UTF-8 encoded Unicode
ar العربية // To use the updated file, open as 8-bit ASCII, copy the strings, and paste
be Беларуская // over the table of names in src/Languages.cpp
bg Български "af Afrikaans",
bn বাংলা "ar العربية",
bs Bosanski "be Беларуская",
ca Català "bg Български",
ca_ES@valencia Valencià "bn বাংলা",
cs Čeština "bs Bosanski",
cy Cymraeg "ca Català",
da Dansk "ca_ES@valencia Valencià",
de Deutsch "cs Čeština",
el Ελληνικά "cy Cymraeg",
en English "da Dansk",
es Español "de Deutsch",
eu Euskara "el Ελληνικά",
eu_ES Euskara (Espainiako) "en English",
fa فارسی "es Español",
fi Suomi "eu Euskara",
fr Français "eu_ES Euskara (Espainiako)",
ga Gaeilge "fa فارسی",
gl Galego "fi Suomi",
he עברית "fr Français",
hi हिन्दी "ga Gaeilge",
hr Hrvatski "gl Galego",
hu Magyar "he עברית",
hy Հայերեն "hi हिन्दी",
id Bahasa Indonesia "hr Hrvatski",
it Italiano "hu Magyar",
ja 日本語 "hy Հայերեն",
ka ქართული "id Bahasa Indonesia",
km ខេមរភាសា "it Italiano",
ko 한국어 "ja 日本語",
lt Lietuvių "ka ქართული",
mk Македонски "km ខេមរភាសា",
my မြန်မာစာ "ko 한국어",
nb Norsk "lt Lietuvių",
nl Nederlands "mk Македонски",
oc Occitan "my မြန်မာစာ",
pl Polski "nb Norsk",
pt Português "nl Nederlands",
pt_BR Português (Brasil) "oc Occitan",
ro Română "pl Polski",
ru Русский "pt Português",
sk Slovenčina "pt_BR Português (Brasil)",
sl Slovenščina "ro Română",
sr_RS Српски "ru Русский",
sr_RS@latin Srpski "sk Slovenčina",
sv Svenska "sl Slovenščina",
ta தமிழ் "sr_RS Српски",
tg Тоҷикӣ "sr_RS@latin Srpski",
tr Türkçe "sv Svenska",
uk Українська "ta தமிழ்",
vi Tiếng Việt "tg Тоҷикӣ",
zh_CN 中文 "tr Türkçe",
zh_TW 中文 "uk Українська",
"vi Tiếng Việt",
"zh_CN 中文",
"zh_TW 中文",

View File

@@ -3071,7 +3071,7 @@
5E15126A1DB0010C00702E29 /* TrackUI.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TrackUI.cpp; sourceTree = "<group>"; }; 5E15126A1DB0010C00702E29 /* TrackUI.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TrackUI.cpp; sourceTree = "<group>"; };
5E15126B1DB0010C00702E29 /* TrackVRulerControls.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TrackVRulerControls.cpp; sourceTree = "<group>"; }; 5E15126B1DB0010C00702E29 /* TrackVRulerControls.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TrackVRulerControls.cpp; sourceTree = "<group>"; };
5E15126C1DB0010C00702E29 /* TrackVRulerControls.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TrackVRulerControls.h; sourceTree = "<group>"; }; 5E15126C1DB0010C00702E29 /* TrackVRulerControls.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TrackVRulerControls.h; sourceTree = "<group>"; };
5E16FF4C1FF9CE0B0085E1B8 /* LanguageNames.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = LanguageNames.txt; path = ../locale/LanguageNames.txt; sourceTree = "<group>"; }; 5E16FF4C1FF9CE0B0085E1B8 /* LanguageNames.txt */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; name = LanguageNames.txt; path = ../locale/LanguageNames.txt; sourceTree = "<group>"; };
5E2A19921EED688500217B58 /* SelectionState.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SelectionState.cpp; sourceTree = "<group>"; }; 5E2A19921EED688500217B58 /* SelectionState.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SelectionState.cpp; sourceTree = "<group>"; };
5E2A19931EED688500217B58 /* SelectionState.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SelectionState.h; sourceTree = "<group>"; }; 5E2A19931EED688500217B58 /* SelectionState.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SelectionState.h; sourceTree = "<group>"; };
5E3FFE701EC9032B0020F7C9 /* NoteTrackSliderHandles.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NoteTrackSliderHandles.cpp; sourceTree = "<group>"; }; 5E3FFE701EC9032B0020F7C9 /* NoteTrackSliderHandles.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NoteTrackSliderHandles.cpp; sourceTree = "<group>"; };

View File

@@ -127,30 +127,77 @@ wxString GetSystemLanguageCode()
void GetLanguages(wxArrayString &langCodes, wxArrayString &langNames) void GetLanguages(wxArrayString &langCodes, wxArrayString &langNames)
{ {
const char *utf8Names[] = {
"af Afrikaans",
"ar العربية",
"be Беларуская",
"bg Български",
"bn বাংলা",
"bs Bosanski",
"ca Català",
"ca_ES@valencia Valencià",
"cs Čeština",
"cy Cymraeg",
"da Dansk",
"de Deutsch",
"el Ελληνικά",
"en English",
"es Español",
"eu Euskara",
"eu_ES Euskara (Espainiako)",
"fa فارسی",
"fi Suomi",
"fr Français",
"ga Gaeilge",
"gl Galego",
"he עברית",
"hi हिन्दी",
"hr Hrvatski",
"hu Magyar",
"hy Հայերեն",
"id Bahasa Indonesia",
"it Italiano",
"ja 日本語",
"ka ქართული",
"km ខេមរភាសា",
"ko 한국어",
"lt Lietuvių",
"mk Македонски",
"my မြန်မာစာ",
"nb Norsk",
"nl Nederlands",
"oc Occitan",
"pl Polski",
"pt Português",
"pt_BR Português (Brasil)",
"ro Română",
"ru Русский",
"sk Slovenčina",
"sl Slovenščina",
"sr_RS Српски",
"sr_RS@latin Srpski",
"sv Svenska",
"ta தமிழ்",
"tg Тоҷикӣ",
"tr Türkçe",
"uk Українська",
"vi Tiếng Việt",
"zh_CN 中文",
"zh_TW 中文",
};
wxArrayString tempNames; wxArrayString tempNames;
wxArrayString tempCodes; wxArrayString tempCodes;
LangHash localLanguageName; LangHash localLanguageName;
LangHash reverseHash; LangHash reverseHash;
LangHash tempHash; LangHash tempHash;
for ( auto utf8Name : utf8Names )
{ {
// The list of locales and associated self-names of languages auto str = wxString::FromUTF8(utf8Name);
// is stored in an external resource file which is easier auto code = str.BeforeFirst(' ');
// to edit as Unicode than C++ source code. auto name = str.AfterFirst(' ');
auto dir = FileNames::ResourcesDir(); localLanguageName[code] = name;
wxTextFile file{dir + wxFILE_SEP_PATH + "LanguageNames.txt"};
file.Open();
for ( auto str = file.GetFirstLine(); !file.Eof();
str = file.GetNextLine() )
{
// Allow commenting-out of languages no longer supported
if (str[0] == '#')
continue;
auto code = str.BeforeFirst(' ');
auto name = str.AfterFirst(' ');
localLanguageName[code] = name;
}
} }
wxArrayString audacityPathList = wxGetApp().audacityPathList; wxArrayString audacityPathList = wxGetApp().audacityPathList;

View File

@@ -98,7 +98,6 @@ Source: "{#AppExe}"; DestDir: "{app}"; Flags: ignoreversion
Source: "..\help\manual\*"; DestDir: "{app}\help\manual\"; Flags: ignoreversion recursesubdirs Source: "..\help\manual\*"; DestDir: "{app}\help\manual\"; Flags: ignoreversion recursesubdirs
Source: "..\presets\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs Source: "..\presets\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs
Source: "..\locale\LanguageNames.txt"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs
; wxWidgets DLLs. Be specific (not *.dll) so we don't accidentally distribute avformat.dll, for example. ; wxWidgets DLLs. Be specific (not *.dll) so we don't accidentally distribute avformat.dll, for example.
; Don't use the WXWIN environment variable, because... ; Don't use the WXWIN environment variable, because...