RinkAttendant6 / JsonI18n

Simple PHP internationalization library using JSON data
Mozilla Public License 2.0
4 stars 1 forks source link

Invalid key fallback #22

Closed NicolasRoehm closed 4 years ago

NicolasRoehm commented 4 years ago

Is it possible to fallback with the given key instead of showing the Invalid key error ?

RinkAttendant6 commented 4 years ago

No, the closest to that would be catching the exception and handling it by outputting the key.

I tend to discourage the use of "method 1" (https://stackoverflow.com/q/10654056/404623) for internationalization, however if that isn't the use case for falling back to the key as a default then I am happy to hear other use cases for that behaviour.

NicolasRoehm commented 4 years ago

I'm used to code with ngx-translate which provides this type of fallback. Precisely, with "method 2" we immediately see which key is missing. When doing front-end work, I prefer to stay focused on the template files and quickly check the result instead of going to the translation file each time I add a key. Another cool thing is that I can add another language and translate the keys gradually and in particular with the context of the screen.

RinkAttendant6 commented 4 years ago

I will consider accepting the feature as a configuration setting if you want to make a pull request.

NicolasRoehm commented 4 years ago

Can you please update the Composer package ? :) Thank you very much!