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'));
}
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.
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>
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.