Skip to content

I18n.Lookup return value #237

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
2 tasks done
vcraescu opened this issue Jan 9, 2019 · 6 comments
Closed
2 tasks done

I18n.Lookup return value #237

vcraescu opened this issue Jan 9, 2019 · 6 comments
Assignees
Labels
enhancement lib-i18n Internationalization/Localization

Comments

@vcraescu
Copy link

vcraescu commented Jan 9, 2019

Lookup function should return the key value if there's no translation for that key. Much easier to debug and there are cases when you need that where you pass a string to that method which is a translation key or just need to print it. There's no way to check if a translation key is valid or not.

  • Implementation
  • Documentation
@jeevatkm
Copy link
Member

jeevatkm commented Jan 9, 2019

@vcraescu Currently function returns empty string and logs key not found as a warning.

aah/i18n/i18n.go

Lines 149 to 151 in 0bb36e0

notExists:
log.Warnf("i18n key not found: %s", key)
return ""

I thought log message would be enough for key not found cases. Seems like its not.

I have a question for you: just a key should be returned or key with some wrapped value. e.g.: ???key.not.found???

@vcraescu
Copy link
Author

vcraescu commented Jan 9, 2019

@jeevatkm Key should be enough. That's how most of the translators are implemented at least in PHP world 😄

Is very helpful when you need to display a text but you don't know if it's a translation key or just a value. There are cases when you would put a translation key into a db field (fast translatable entities 😄) and sometimes you just need to display the value as it is. If the translation function returns the key if no translation found it makes possible to create generic template function which will display either the translation or the raw value.

Not very good at explaining stuff just hope it makes sense.

@jeevatkm
Copy link
Member

jeevatkm commented Jan 9, 2019

@vcraescu understood 😄

@jeevatkm jeevatkm added enhancement lib-i18n Internationalization/Localization labels Jan 9, 2019
@jeevatkm jeevatkm added this to the v0.13.0 Milestone milestone Jan 9, 2019
jeevatkm added a commit that referenced this issue Jan 10, 2019
@jeevatkm jeevatkm self-assigned this Jan 10, 2019
jeevatkm added a commit to go-aah/docs that referenced this issue Jan 11, 2019
jeevatkm added a commit that referenced this issue Jan 11, 2019
@jeevatkm
Copy link
Member

Its done 😄

@vcraescu
Copy link
Author

thanks! 👍

@jeevatkm
Copy link
Member

@vcraescu You're welcome. You could try the implementation and please share your feedback.

Add to go.mod

replace aahframe.work => aahframe.work v0.0.0-20190111183604-b1a2826abfb3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement lib-i18n Internationalization/Localization
Projects
None yet
Development

No branches or pull requests

2 participants