i18next / ng-i18next

translation for AngularJS using i18next
https://github.com/i18next/ng-i18next
MIT License
161 stars 54 forks source link

i18next storing missing keys on scope and is not overriding them when added to $i18next #132

Closed aubrey-fowler closed 6 years ago

aubrey-fowler commented 7 years ago

I am trying to integrate the ng-i18next library into my angular 1.5.3 project.

https://github.com/i18next/ng-i18next

I have been playing around with this library and I have seen some really strange results.

Here is my index.html file:

<!DOCTYPE html>

Hello, {{name}}!

Here's my app.js file:

if (window.i18next) { window.i18next.init({ debug: true, lng: 'en', // If not given, i18n will detect the browser language. fallbackLng: 'en', // Default is dev resources: {}, useCookie: false, useLocalStorage: false, joinArrays: '
' }); }

var myApp = angular.module('myApp', ['ngSanitize', 'jm.i18next']); myApp.controller('MyCtrl', MyCtrl);

function MyCtrl($scope, $i18next) { $scope.name = 'Superhero';

console.log($i18next.t('HELLO'));

$i18next.i18n.addResourceBundle('en', 'translation', { 'HELLO': 'hiya' });

console.log($i18next.t('HELLO')); } This first console log statement has an impact on the results! If I comment it out then my code works it prints out hiya if I don't it doesn't work and prints out HELLO. There is something very strange going on here and I don't know how to get it to work properly.

anwalkers commented 7 years ago

Do you have resources loaded in i18next? Are you using a loader or using static resources?