observable_translation Module

Observable Translations for kivy that change when the language changes.

The functionality of this module is highly inspired by kivy-gettext-example <https://github.com/tito/kivy-gettext-example>.

class kniteditor.localization.observable_translation.ObservableTranslation(translate)[source]

Bases: kivy._event.Observable

This class allows kivy translations to be updated with the language.

__call__(text)[source]

Call this object to translate text.

Parameters:text (str) – the text to translate
Returns:the text translated to the current language
__init__(translate)[source]

Create a new translation object with a translation function.

Parameters:translate – a callable that translates the text. Even when the language is changed, it returns the text for the currrent language.
__weakref__

list of weak references to the object (if defined)

fbind(name, func, args, **kwargs)[source]

Add an observer. This is used by kivy.

funbind(name, func, args, **kwargs)[source]

Remove an observer. This is used by kivy.

language_changed()[source]

Update all the kv rules attached to this text.