2

My main page (root) contains observable named levelvalue and is saving some value to it.

The html is as follows in the child page:

<ol>
    <li><span data-bind="attr:{id:$root.levelvalue,'data-i18n':$root.levelvalue}"></span>
    </li>
</ol>

The problem is that the value inside <li> is not showing up in the browser even though the value shows up properly inside browser developer tools (F12) as below:

<span data-bind="attr:{'data-i18n':$root.levelvalue}" data-i18n="applications"/>

Is this a problem with i18n translation?

Note: all other values on the page shows up properly even using i18n.

Rahul Dawn
  • 19
  • 5
  • At what point does i18next translate the page (not something I've used)? If it's done on page load for instance, knockout will be setting the attribute after it's happened. You'll need some way to re-trigger i18next to run - the ideal route would probably be a custom binding handler to link the two things together. – James Thorpe Jan 19 '16 at 10:35
  • What library are you using for i18n? – JotaBe Jan 19 '16 at 10:42
  • @JotaBe Question is tagged i18next, so I assume it's [this one](http://i18next.com/), though not specifically mentioned in the question itself. – James Thorpe Jan 19 '16 at 10:50
  • A quick google seems to show that there's [at least one](http://jsfiddle.net/remisture/GxEGe/) binding handler already, and also maybe a [duplicate question](http://stackoverflow.com/questions/22760457/how-to-use-knockout-observables-in-i18next) – James Thorpe Jan 19 '16 at 10:52
  • i18next-1.6.3.............the issue is very confusing as browser tool shows that proper value is getting loaded to 'data-i18n' attribute. but no Text property is getting loaded by i18n. – Rahul Dawn Jan 19 '16 at 11:26
  • The question needs more code, i.e. it needs a [mcve]. – Jeroen Jan 19 '16 at 14:36

1 Answers1

0

Loading a blank pop up (template) with below code in its viewmodel solves the issue:

i18n.init({
            "lng": 'en',
            "debug": true,
            "fallbackLng": 'en',
            "resGetPath": AppConstants.get('LOCALIZEDPATH') + '/__ns__-__lng__.json',
            ns: {
                namespaces: ['resource'],
                defaultNs: 'resource'
            }
        }, function (call) {
            $(document).i18n();
        });

Looking for a better solution...

Rahul Dawn
  • 19
  • 5