-
Notifications
You must be signed in to change notification settings - Fork 327
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
[Proposal] I18n with keys/identifiers and strings to be translated #567
Comments
I think with "Storing identifiers" be better to translate phrases and big paragraphs. "Storing the translated string" does not seem to be suitable for large paragraphs. |
@sudeste, exactly. The proposal is to store both, identifier and full string, in a single array element, in order:
|
@enov I like this, although it does feel like keeping it backward compatible makes the method API a bit uncomfortable - since otherwise you would presumably just do Either that, or add a new method with a clean signature for this and deprecate the old one which would make it easier to find old-style usage. Is there potential confusion between this and the kohana messages - which are also using key lookups but in totally separate tables? |
Yeah, it does make the API a bit uncomfortable.
Note that the |
@enov Definitely a new method in Similarly having Why not just I do still think there's also an issue that we have I18n lookups and Kohana::message which would now do similar things (neither directly supporting parameters) and then also code dotted around other places eg in Validation that does If I was going to design from scratch, I'd possibly consider making each distinct message a data class of some kind that could hold both the key and any expected params, and then a service class that can look up the appropriate translation and deal with replacements - and use that to replace both Kohana::message and I18n::translate. So the view would look something like: <p><?=message(new \Application\Message\WelcomeTextMessage($username));?></p> Or you'd potentially handle that in a view model and just pass the resultant string to the template. Maybe that's overkill for simple strings though, I dunno, and it would certainly not be BC. |
Sorry revive it post. I rethought this case a few days. I used "Zend-i18n / Gettext" and works perfectly for full texts |
Hello all!
This is a proposal to enhance the Kohana I18n system to allow look up with keys while at the same time keeping the strings that needs to be translated in full and in its default language within the views.
There has been numerous discussions regarding whether to store the identifiers or the whole strings within the
i18n
dictionary folder. Both approaches have their advantages and disadvantages. This is to propose declaring both (identifier/key and whole string) in the View, like so:Then in the dictionary file you set:
I have a tentative code that makes this work, it just changes
I18n::get
and it is fully compatible with string only version we have already. This works whether you use identifiers, whole strings or an array of both, as described in this proposal.References:
http://blog.mixu.net/2010/11/11/kohana-3-i18n-tutorial/
http://forum.kohanaframework.org/discussion/comment/24814/
http://forum.kohanaframework.org/discussion/comment/41757/
The text was updated successfully, but these errors were encountered: