Plato on Github
Report Home
translate.js
Maintainability
64.27
Lines of code
42
Difficulty
11.15
Estimated Errors
0.19
Function weight
By Complexity
By SLOC
/** * @ngdoc overview * @name pascalprecht.translate * * @description * The main module which holds everything together. */ angular.module('pascalprecht.translate', ['ng']) .run(runTranslate); function runTranslate($translate) { 'use strict'; var key = $translate.storageKey(), storage = $translate.storage(); var fallbackFromIncorrectStorageValue = function () { var preferred = $translate.preferredLanguage(); if (angular.isString(preferred)) { $translate.use(preferred); // $translate.use() will also remember the language. // So, we don't need to call storage.put() here. } else { storage.put(key, $translate.use()); } }; fallbackFromIncorrectStorageValue.displayName = 'fallbackFromIncorrectStorageValue'; if (storage) { if (!storage.get(key)) { fallbackFromIncorrectStorageValue(); } else { $translate.use(storage.get(key))['catch'](fallbackFromIncorrectStorageValue); } } else if (angular.isString($translate.preferredLanguage())) { $translate.use($translate.preferredLanguage()); } } runTranslate.displayName = 'runTranslate';