Skip to content

added method get_translations(field_name)#7

Open
amirnissim wants to merge 2 commits intozmathew:masterfrom
amirnissim:master
Open

added method get_translations(field_name)#7
amirnissim wants to merge 2 commits intozmathew:masterfrom
amirnissim:master

Conversation

@amirnissim
Copy link
Copy Markdown

useful for checking user entered input against all translations of a translatable field

linguo/models.py Outdated
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

I wonder if we should return a dict mapping language to translation instead. Otherwise it could be ambiguous as to which language a translation belong to.
For example, if you have languages en and fr (in that order), but you don't have a translation for 'en'. get_translations will return ['something'] but you won't know which language that is.

@amirnissim
Copy link
Copy Markdown
Author

@zmathew
I agree, changed to return dict.
It is still easy enough to get the list of translated strings:

obj.get_translations('name').values()
-> ['English_name', 'French_name']

and it is now easy to test if there is a translation for a language:

'en' in obj.get_translations('name')
-> True

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.

2 participants