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

i18n support #42

Open
taai opened this issue Aug 2, 2012 · 3 comments
Open

i18n support #42

taai opened this issue Aug 2, 2012 · 3 comments

Comments

@taai
Copy link

taai commented Aug 2, 2012

It would be great, if KOstache supported i18n (internationalization).

It's very easy to implement. Just add this function to the Kohana_Kostache class:

<?php
    public function i18n()
    {
        return array('I18n', 'get');
    }

Then it will be possible to use i18n in templates:

<label for="user_email">{{#i18n}}Email{{/i18n}}</label>
@shadowhand
Copy link
Contributor

If you make a pull request, I'll merge it.

taai pushed a commit to taai/KOstache that referenced this issue Aug 6, 2012
@ingenb
Copy link

ingenb commented Dec 23, 2012

I would like to propose a different mechanism for I18N support in KOstache: Use language-specific template files.
In this scheme, if I18N support is requested, the template loader (Mustache_Loader_Kohana) would first look in a language-dependent sub-directory of where it normally looks for the templates. The search should use the same algorithm as the I18n class in Kohana itself.

As an example, take the following directory tree:

  • templates
    • foo.mustache
    • en
      • foo.mustache
      • GB
        • foo.mustache

A user with British locale (en-GB) would get "templates/en/GB/foo.mustache".
A user with American locale (en-US) or unspecified English (en) would get "templates/en/foo.mustache"
A user with some other locale (for example, de) would get "templates/foo.mustache"

It is then up to the developers to decide which views could benefit from I18N and to provide the relevant translated templates.

@zombor
Copy link
Owner

zombor commented Dec 23, 2012

I think implementing i18n is best left to the developer in a way that makes sense to them.

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

4 participants