Skip to content

small fixes to get a runable example:#10

Open
AndiEcker wants to merge 1 commit into
tito:masterfrom
AndiEcker:fix_args_and_return_in_fbind_funbind
Open

small fixes to get a runable example:#10
AndiEcker wants to merge 1 commit into
tito:masterfrom
AndiEcker:fix_args_and_return_in_fbind_funbind

Conversation

@AndiEcker

Copy link
Copy Markdown

first big thanks @tito for this example which is the most clean one I found for to implement i18n into kivy apps. This PR is fixing some small bugs that may help others in the future:

  • fixed declaration of args in fbind()/funbind() like declared in _events module.
  • removed unneeded return statement in fbind()/funbind().
  • corrected first parameter for notification func (from args to args[0]).

- fixed declaration of args in fbind()/funbind() like declared in _events module.
- removed unneeded return statement in fbind()/funbind().
- corrected first parameter for notification func (from args to args[0]).
Comment thread main.py
@@ -18,29 +18,29 @@ def __init__(self, defaultlang):
def _(self, text):

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

optional extension: by re-declaring the method _ into __call__ one could instantiate the Lang class directly to a variable with the name _ like so _ = Lang("en") and with that the tr._("translate me") could be replaced by `_("translate me"), and use it like in the original gettext C implementation.

Comment thread main.py
self.observers.append((func, args, kwargs))
else:
return super(Lang, self).fbind(name, func, *largs, **kwargs)
super(Lang, self).fbind(name, func, *args, **kwargs)

@AndiEcker AndiEcker Jul 20, 2020

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just noticed in the kivy documentation (https://kivy.org/doc/stable/api-kivy.event.html) that fbind should actually return an uid. For to accomplish this how would the uid be created for the case where name == '_' ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant