Skip to content

How to translate i2pd web console to your language

R4SAS edited this page Jun 15, 2021 · 5 revisions

Translation support for web console was added, so you can translate it to your language.

Using Crowdin

You can translate i2pd to your language on Crowdin. Account required on service to make translations.

For adding new language open discussion on platform. Translations will be pulled manually before release or at any time to trunk.

Manually

For translation take Russian translation code (as most complete), 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:
 namespace i18n
 {
-namespace russian // language
+namespace turkmen // language
 {
  1. Update plural form function using information from https://localization-guide.readthedocs.io/en/latest/l10n/pluralforms.html:
 	// 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;
 	}
  1. Update translatable strings and numeric strings in plural form:
 	static std::map<std::string, std::string> 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<std::string, std::vector<std::string>> plurals
 	{
 		// ShowUptime
-		{"days",    {"день", "дня", "дней"}},
-		{"hours",   {"час", "часа", "часов"}},
+		{"days",    {"gün", "gün"}},
+		{"hours",   {"sagat", "sagat"}},
 ...

Note: you can left strings without translation, so use line commenting with // at line start to skip them.

  1. Add language namespace in i18n header file I18N_langs.h:
 	namespace english { std::shared_ptr<const i2p::i18n::Locale> GetLocale (); }
 	namespace russian { std::shared_ptr<const i2p::i18n::Locale> GetLocale (); }
+	namespace turkmen { std::shared_ptr<const i2p::i18n::Locale> GetLocale (); }
 ...

and in I18N.h:

 	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());
  1. Add commentary about new added language to i2pd.conf:
-## Currently supported english (default), russian and ukrainian languages
+## Currently supported english (default), russian, turkmen and ukrainian languages
 # lang = english
  1. Make pull request with changes or send your translation file to r4sas <at> i2pd <dot> xyz to add translation anonymously.