From 4645802c82172744d26c39276efe6287868c2e46 Mon Sep 17 00:00:00 2001 From: R4SAS Date: Mon, 14 Jun 2021 11:31:58 +0300 Subject: [PATCH] Created [i18n] How to translate i2pd web console to your language (markdown) --- ...slate-i2pd-web-console-to-your-language.md | 75 +++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 [i18n]-How-to-translate-i2pd-web-console-to-your-language.md diff --git a/[i18n]-How-to-translate-i2pd-web-console-to-your-language.md b/[i18n]-How-to-translate-i2pd-web-console-to-your-language.md new file mode 100644 index 0000000..a324f78 --- /dev/null +++ b/[i18n]-How-to-translate-i2pd-web-console-to-your-language.md @@ -0,0 +1,75 @@ +Translation support for web console was added, so you can translate it to your language. + +For translation take [Russian translation](https://github.com/PurpleI2P/i2pd/blob/openssl/i18n/Russian.cpp) code, make copy with your language name as file name, and update strings in it. + +In that example will be used Turkmen as target language + +# Translation steps + +1. Update translation namespace to your language: +```diff + namespace i18n + { +-namespace russian // language ++namespace turkmen // language + { +``` + +2. Update plural form function using information from https://localization-guide.readthedocs.io/en/latest/l10n/pluralforms.html: +```diff + // See for language plural forms here: + // https://localization-guide.readthedocs.io/en/latest/l10n/pluralforms.html + static int plural (int n) { +- return n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2; ++ return n != 1 ? 1 : 0; + } +``` + +3. Update translatable strings and numeric strings in plural form: +```diff + static std::map strings + { + // HTTP Proxy +- {"Proxy error", "Ошибка прокси"}, +- {"Proxy info", "Информация прокси"}, +- {"Proxy error: Host not found", "Ошибка прокси: Адрес не найден"}, ++ {"Proxy error", "Proksi ýalňyşlygy"}, ++ {"Proxy info", "Proksi maglumat"}, ++ {"Proxy error: Host not found", "Proksi ýalňyşlygy: Host tapylmady"}, + ... + static std::map> plurals + { + // ShowUptime +- {"days", {"день", "дня", "дней"}}, +- {"hours", {"час", "часа", "часов"}}, ++ {"days", {"gün", "gün"}}, ++ {"hours", {"sagat", "sagat"}}, + ... +``` + +4. Add language namespace in i18n header file [`I18N_langs.h`](https://github.com/PurpleI2P/i2pd/blob/e412b17f709af249ffa20a08cb111090631e8d0e/i18n/I18N_langs.h#L61): +```diff + namespace english { std::shared_ptr GetLocale (); } + namespace russian { std::shared_ptr GetLocale (); } ++ namespace turkmen { std::shared_ptr GetLocale (); } + ... +``` + +and in [`I18N.h`](https://github.com/PurpleI2P/i2pd/blob/e412b17f709af249ffa20a08cb111090631e8d0e/i18n/I18N.h#L22-L23): +```diff + inline void SetLanguage(const std::string &lang) + { + if (!lang.compare("russian")) + i2p::context.SetLanguage (i2p::i18n::russian::GetLocale()); ++ else if (!lang.compare("turkmen")) ++ i2p::context.SetLanguage (i2p::i18n::turkmen::GetLocale()); +``` + +5. Add commentary about new added language to [`i2pd.conf`](https://github.com/PurpleI2P/i2pd/blob/e412b17f709af249ffa20a08cb111090631e8d0e/contrib/i2pd.conf#L107): +```diff +-## Currently supported english (default), russian and ukrainian languages ++## Currently supported english (default), russian, turkmen and ukrainian languages + # lang = english +``` + +6. Make pull request with changes \ No newline at end of file