This commit is contained in:
yumoqing 2022-08-26 11:00:33 +08:00
parent f8c0dbedc0
commit 89343bb43e
3 changed files with 8 additions and 4 deletions

View File

@ -84,4 +84,5 @@ if you running it on window, it will show the following:
Build app for android please see [Buildozer](https://github.com/kivy/buildozer) Build app for android please see [Buildozer](https://github.com/kivy/buildozer)
kivy introduct and API please see [kivy](https://kivy.org) kivy introduct and API please see [kivy](https://kivy.org)
## Changelog
[changelog](docs/changelog.md)

View File

@ -3,4 +3,5 @@
## version 0.3.0 ## version 0.3.0
add script to support local .tmpl and .dspy file translation. it can build dynamic user interface without remote server. add script to support local .tmpl and .dspy file translation. it can build dynamic user interface without remote server.
## version 0.3.1
* uses weakref to collect all the i18n widgets in i18n.py

View File

@ -1,6 +1,6 @@
import os import os
import codecs import codecs
from weakref import ref
import locale import locale
from kivy.app import App from kivy.app import App
from kivy.properties import StringProperty from kivy.properties import StringProperty
@ -18,7 +18,7 @@ class I18n:
self.i18nWidgets = [] self.i18nWidgets = []
def addI18nWidget(self,w): def addI18nWidget(self,w):
self.i18nWidgets.append(w) self.i18nWidgets.append(ref(w))
def loadI18nFromI18nFolder(self, lang): def loadI18nFromI18nFolder(self, lang):
config = gtConfig() config = gtConfig()
@ -63,6 +63,8 @@ class I18n:
if not d: if not d:
self.loadI18n(lang) self.loadI18n(lang)
self.lang = lang self.lang = lang
ws = [ w for w in self.i18nWidgets if w is not None ]
self.i18nWidgets = ws
for w in self.i18nWidgets: for w in self.i18nWidgets:
w.changeLang(lang) w.changeLang(lang)