Giter VIP home page Giter VIP logo

Comments (4)

peterlukerow avatar peterlukerow commented on June 20, 2024 1

Excellent, thanks for the jsFiddles, :)

from jquery-i18next.

jamuhl avatar jamuhl commented on June 20, 2024

are you sure...i think the behaviour is consistent - if there is no text found it will show the key instead -> to show devs, translators, who ever -> you forgot something: while an empty string just does not attracts attention for a mistake.

there are tons of options reading the docs:

  1. set a fallbackLng (so if no translation is found the sourcelanguage / fallback is shown
  2. override parseMissingKeyHandler: https://www.i18next.com/configuration-options.html#missing-keys

from jquery-i18next.

peterlukerow avatar peterlukerow commented on June 20, 2024

Yes I'm sure. In my test I had fallback language, but if your current and fallback language are the same then obviously that has no effect.

Plus it is not consistent, see my 2nd example, I'll repeat it here, if you have <h2 data-i18l="namespace.page.title"></h2> and both the current and fallback language don't have that defined then you get <h2 data-i18l="namespace.page.title"></h2> in your page, you do not get <h2 data-i18l="namespace.page.title">namespace.page.title</h2> as you suggest. The only time it behaves like that (which is why I raised this bug) is when you are trying to set the value of an attribute with it.

If the plugin is suppose to work as you say then the bug is the other way around.

I guess I should admit that in the test scenario that I'm investigating using this for we are not using this for translation per say, but as a way for customers to change text on a page without us having to add special fields for them. We simply add in the markup for the page and if they want to override the default then so be it we just add a resource JSON file for that namespace for their "language", but if they don't or there is no default you don't get pointless key text.

from jquery-i18next.

jamuhl avatar jamuhl commented on June 20, 2024

ok...sorry...now found the cause. Hard to remember special cases for all the framework integrations of i18next ;)

on h2 it does show empty string as it takes by default the current initial value of the h2 as defaultValue for translations -> so it shows '' instead of key (while showing key would be default in pure i18next).

you can set 'parseDefaultValueFromContent: false' https://github.com/i18next/jquery-i18next#initialize-the-plugin

sample -> https://jsfiddle.net/yueLnwqz/

But anyway you want the '' anyway -> see https://jsfiddle.net/apnd4dnx/ uses the parseMissingKeyHandler

from jquery-i18next.

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.