Package: kivy-translate
kivy_translateEasy translations for kivy (not only) projectsSimple tool to make python applications available in multiple languages.Simple collecting translable messages to PO filesSimple compiling PO files to MO filesKivy translate have 2 parts:kivy_translate tool - collect and compile messagesHandler in runtime to translate messages on flyNOTECode is not well tested, some bugs may exist, message me if something is not ok.InstallationJust:pip install kivy_translateUsage kivy_translate toolInvoke it from main folder of project (same place wheremain.pyis)Usage:
    kivy_translate [target] [--verbose]

Available modes:
    get        Collect all translable strings across project - string should be in `_('string')`
    make       Compile all PO files for all supported languages.kivy_translate.cfgYou can use custom translation setting file.It should be in same folder wheremain.pyis.Example.kivy_translate.cfgfile[settings]
supported_languages = ["en", "pl"]

; not implemented yet
translator_name = Firstname Lastname
translator_email = translator@example.com

[files]
main_file = main.py
excluded_folders = [".git", ".buildozer", "__pycache__", "bin"]

; 'kv' not implemented yet
filter_extensions = [".py", ".kv"]Usage translations inside appNOTEAfter version 0.2.0Transclass have to be imported from package.You need to make a file with translationse.g.:./translations/translations.pyfrom kivy_translate.kvtranslate import Trans

py_translations = {
    "English": Trans._("English"),
    "Polish": Trans._("Polish"),
    "German": Trans._("German"),
    "Spanish": Trans._("Spanish"),
}

kv_translations = {
    "Close": Trans._("Close"),
    "Save": Trans._("Save"),
}keyis string_identifiervalueis translable stringpy_translationsare translations used by pure pythone.g.:label = Label(text=Trans._("English"))kv_translationsare used in .kve.g.:Label:
    text: app.trans['Save']They will change whenTrans.refresh_translations()is calledNOTEAll missing strings (not included inkv_translations)
will be replaced with "???????"Transmethodsget_current_language()- returns current language for appswitch_language(<lang>)- change language for gettext and bind it to app. accepts 2 letter code (en, pl, es, de etc...)refresh_translations()- reloads all .kv translations on fly (kivy only)Minimum setup#!/usr/bin/env python

from kivy.app import App
from kivy.properties import ObjectProperty

from kivy_translate.kvtranslate import Trans

class MainApp(App):
    trans = ObjectProperty()
    settings = ObjectProperty()

    def _init_app(self):
        self.settings = {"lang": "en"}
        lang = self.settings.get("lang", "en")
        self._init_translations(lang)

    def _init_translations(self, lang):
        Trans.switch_language(lang.lower())
        from translations.translations import kv_translations

        Trans.kv_translations = kv_translations
        Trans.refresh_translations()

    def build(self):
        self._init_app()
        your code...
        your code...
        your code...


if __name__ == "__main__":
    MainApp().run()All should work nowNOTETo change language on flyTrans.switch_language(new_lang)
Trans.refresh_translations()NOTERemember to collect and compile messages !NOTETo use kivy_translate with kivy importfrom kivy_translate.kvtranslate import TransTo use kivy_translate with generic python importfrom kivy_translate.translate import TransSupportIf you need assistance, you can ask for help by email:Email:dev@stacja1.plLicensekivy_translate is released under the terms of the MIT License.Please refer to the LICENSE file.