GithubHelp home page GithubHelp logo

Internationalization about tko HOT 6 OPEN

knockout avatar knockout commented on July 19, 2024
Internationalization

from tko.

Comments (6)

krnlde avatar krnlde commented on July 19, 2024 1

I worked with i18next and its adapters to angular a lot in the past. To me it feels really slick and natural. If you take knockout.punches into account you could solve it through piping as in angular:

<span>{{'general.greet' | translate::username}}</span>

Though the way the filter parameters are passed in ko.punches could be improved like so:

<span>{{'general.greet' | translate: {name: username} }}</span>

That way you would have named parameters and you wouldn't introduce a new syntax, instead you'd have an ordinary JavaScript object.

Number and Date formatting is not provided by i18next afaik.
edit: apparently it does: http://i18next.com/translate/formatting/

from tko.

brianmhunt avatar brianmhunt commented on July 19, 2024

Given a binding translator (like i18next), there are three ways I think it could be employed:

  1. A binding provider (i.e. tko.provider.i18n) - converts text nodes by running them through a binding-translator based on some criteria/regex/etc
  2. an explicit i18n binding works like, or pairs with, the text binding
  3. one or more i18n filters that pluralize/etc

A sane strategy for one or more of these probably requires delving into what others do.

from tko.

krnlde avatar krnlde commented on July 19, 2024

I wouldn't suggest using an explicit i18n-binding since it limits the possibilities to work with i18n. Think of attribute-values like placeholder or title. Think of combining multiple keys.
The rest is totally cool :)

from tko.

miellaby avatar miellaby commented on July 19, 2024

To limit documentation effort, and despite API inconsistency, I'd suggest a provider of the exactly same syntax as https://github.com/i18next/jquery-i18next with the extra requiment that data-i18n-options might be subscribable and trigger a new translation when changing. Also this syntax is supported by https://github.com/i18next/i18next-parser

from tko.

brianmhunt avatar brianmhunt commented on July 19, 2024

@miellaby those are fantastic suggestions, thank you

from tko.

brianmhunt avatar brianmhunt commented on July 19, 2024

Noting: https://metacpan.org/pod/distribution/Locale-Maketext/lib/Locale/Maketext/TPJ13.pod?_ke=eyJrbF9lbWFpbCI6ICJicmlhbm1odW50QGdtYWlsLmNvbSIsICJrbF9jb21wYW55X2lkIjogImU3WUMzdSJ9#A_Localization_Horror_Story:_It_Could_Happen_To_You

from tko.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.