[vlc-devel] [PATCH] gui/qt: simple_preferences: combine ppsz_language and ppsz_language_map
Filip Roséen
filip at atch.se
Sat Feb 25 07:30:39 CET 2017
Having things as two separate arrays is very hard to maintain as one
entry in ppsz_language must correctly correspond to one element in
ppsz_language_text.
These changes refactors the implementation so that a single array is
used, where each element has two members so that it is easier to see
what corresponds to what.
--
I hope that this email gets sent with the correct encoding.
*fingers crossed*
---
modules/gui/qt/components/simple_preferences.cpp | 201 ++++++++---------------
1 file changed, 70 insertions(+), 131 deletions(-)
diff --git a/modules/gui/qt/components/simple_preferences.cpp b/modules/gui/qt/components/simple_preferences.cpp
index e9c0133942..b9e1d01a41 100644
--- a/modules/gui/qt/components/simple_preferences.cpp
+++ b/modules/gui/qt/components/simple_preferences.cpp
@@ -54,134 +54,73 @@
# include <shobjidl.h>
#endif
#include <vlc_modules.h>
-
-static const char *const ppsz_language[] =
-{
- "auto",
- "en",
- "ar",
- "bn",
- "pt_BR",
- "en_GB",
- "el",
- "bg",
- "ca",
- "zh_TW",
- "cs",
- "cy",
- "da",
- "nl",
- "fi",
- "et",
- "eu",
- "fr",
- "ga",
- "gd",
- "gl",
- "ka",
- "de",
- "he",
- "hr",
- "hu",
- "hy",
- "is",
- "id",
- "it",
- "ja",
- "ko",
- "lt",
- "mn",
- "ms",
- "nb",
- "nn",
- "kk",
- "km",
- "ne",
- "oc",
- "fa",
- "pl",
- "pt_PT",
- "pa",
- "ro",
- "ru",
- "zh_CN",
- "si",
- "sr",
- "sk",
- "sl",
- "ckb",
- "es",
- "sv",
- "te",
- "tr",
- "uk",
- "vi",
- "wa",
- NULL,
-};
-
-static const char *const ppsz_language_text[] =
-{
- N_("Auto"),
- "American English",
- "ﻉﺮﺒﻳ",
- "বাংলা",
- "Português Brasileiro",
- "British English",
- "Νέα Ελληνικά",
- "български език",
- "Català",
- "正體中文",
- "Čeština",
- "Cymraeg",
- "Dansk",
- "Nederlands",
- "Suomi",
- "eesti keel",
- "Euskara",
- "Français",
- "Gaeilge",
- "Gàidhlig",
- "Galego",
- "ქართული",
- "Deutsch",
- "עברית",
- "hrvatski",
- "Magyar",
- "հայերեն",
- "íslenska",
- "Bahasa Indonesia",
- "Italiano",
- "日本語",
- "한국어",
- "lietuvių",
- "Монгол хэл",
- "Melayu",
- "Bokmål",
- "Nynorsk",
- "Қазақ тілі",
- "ភាសាខ្មែរ",
- "नेपाली",
- "Occitan",
- "ﻑﺍﺮﺳی",
- "Polski",
- "Português",
- "ਪੰਜਾਬੀ",
- "Română",
- "Русский",
- "简体中文",
- "සිංහල",
- "српски",
- "Slovensky",
- "slovenščina",
- "کوردیی سۆرانی",
- "Español",
- "Svenska",
- "తెలుగు",
- "Türkçe",
- "украї́нська мо́ва",
- "tiếng Việt",
- "Walon",
+#include <vlc_arrays.h>
+
+static struct {
+ const char iso[6];
+ const char name[34];
+
+} const language_map[] = {
+ { "auto", N_("Auto") },
+ { "en", "American English" },
+ { "ar", "ﻉﺮﺒﻳ" },
+ { "bn", "বাংলা" },
+ { "pt_BR", "Português Brasileiro" },
+ { "en_GB", "British English" },
+ { "el", "Νέα Ελληνικά" },
+ { "bg", "български език" },
+ { "ca", "Català" },
+ { "zh_TW", "正體中文" },
+ { "cs", "Čeština" },
+ { "cy", "Cymraeg" },
+ { "da", "Dansk" },
+ { "nl", "Nederlands" },
+ { "fi", "Suomi" },
+ { "et", "eesti keel" },
+ { "eu", "Euskara" },
+ { "fr", "Français" },
+ { "ga", "Gaeilge" },
+ { "gd", "Gàidhlig" },
+ { "gl", "Galego" },
+ { "ka", "ქართული" },
+ { "de", "Deutsch" },
+ { "he", "עברית" },
+ { "hr", "hrvatski" },
+ { "hu", "Magyar" },
+ { "hy", "հայերեն" },
+ { "is", "íslenska" },
+ { "id", "Bahasa Indonesia" },
+ { "it", "Italiano" },
+ { "ja", "日本語" },
+ { "ko", "한국어" },
+ { "lt", "lietuvių" },
+ { "mn", "Монгол хэл" },
+ { "ms", "Melayu" },
+ { "nb", "Bokmål" },
+ { "nn", "Nynorsk" },
+ { "kk", "Қазақ тілі" },
+ { "km", "ភាសាខ្មែរ" },
+ { "ne", "नेपाली" },
+ { "oc", "Occitan" },
+ { "fa", "ﻑﺍﺮﺳی" },
+ { "pl", "Polski" },
+ { "pt_PT", "Português" },
+ { "pa", "ਪੰਜਾਬੀ" },
+ { "ro", "Română" },
+ { "ru", "Русский" },
+ { "zh_CN", "简体中文" },
+ { "si", "සිංහල" },
+ { "sr", "српски" },
+ { "sk", "Slovensky" },
+ { "sl", "slovenščina" },
+ { "ckb", "کوردیی سۆرانی" },
+ { "es", "Español" },
+ { "sv", "Svenska" },
+ { "te", "తెలుగు" },
+ { "tr", "Türkçe" },
+ { "uk", "украї́нська мо́ва" },
+ { "vi", "tiếng Việt" },
+ { "wa", "Walon" }
};
static int getDefaultAudioVolume(vlc_object_t *obj, const char *aout)
@@ -721,8 +660,8 @@ SPrefsPanel::SPrefsPanel( intf_thread_t *_p_intf, QWidget *_parent,
#ifndef _WIN32
ui.langBox->hide();
#else
- for( int i = 0; ppsz_language[i] != NULL; i++)
- ui.langCombo->addItem( qfu(ppsz_language_text[i]), ppsz_language[i]);
+ for( int i = 0; i < ARRAY_SIZE( language_map ); i++)
+ ui.langCombo->addItem( qfu( language_map[i].name ), language_map[i].iso );
CONNECT( ui.langCombo, currentIndexChanged( int ), this, langChanged( int ) );
HKEY h_key;
@@ -1187,7 +1126,7 @@ void SPrefsPanel::changeStyle( QString s_style )
void SPrefsPanel::langChanged( int i )
{
free( lang );
- lang = strdup( ppsz_language[i] );
+ lang = strdup( language_map[i].iso );
}
void SPrefsPanel::configML()
--
2.11.1
More information about the vlc-devel
mailing list