Skip to content
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

lang bug or not? (empty translations) #1698

Closed
nowackipawel opened this issue Jan 31, 2019 · 3 comments
Closed

lang bug or not? (empty translations) #1698

nowackipawel opened this issue Jan 31, 2019 · 3 comments

Comments

@nowackipawel
Copy link
Contributor

nowackipawel commented Jan 31, 2019

Is it a bug that lang('File.key') returns File.key for a value defined as empty string?
I think it will be correct as long as key does not exist in File.php array but not in case like null or ''.
Is there a way to define empty translation items?

@nowackipawel nowackipawel changed the title lang bug or not? lang bug or not? (empty translations) Jan 31, 2019
@lonnieezell
Copy link
Member

Well, I'm sure it probably uses an isset check instead of array_key_exists and that could probably be easily changed. That was intentional, though, so that it was easy to spot missing language strings.

I'm curious about the need for empty translation strings, though?

@jim-parry
Copy link
Contributor

That was done on purpose, so that lang(x) would not fail even with missing translations.
It is part of the intended cascading, i.e checking fr-CA then fr then en, and returning the key if there was no translation.

@jim-parry
Copy link
Contributor

btw, an empty message value doesn't sound very helpful.
Eg. the following error occurred: ""
I suggest you provide your own app/Library/Language class, perhaps extending the built-in one, which provides the behavior you would like. You could then provide an over-riding language() method in app/Config/Services to return it.

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

No branches or pull requests

3 participants