blob: 6129c708619b14ff02a2529d1913cd21fe0cde0c [file] [log] [blame]
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
require('core-js');
require('zone.js');
require('hammerjs');
var $ = require('jquery');
var FdsModule = require('demo-app/fds.module.js');
var ngPlatformBrowserDynamic = require('@angular/platform-browser-dynamic');
var ngCore = require('@angular/core');
// Comment out this line when developing to assert for unidirectional data flow
ngCore.enableProdMode();
// Get the locale id from the global
var locale = navigator.language;
var providers = [];
// No locale or U.S. English: no translation providers so go ahead and bootstrap the app
if (!locale || locale === 'en-US') {
ngPlatformBrowserDynamic.platformBrowserDynamic().bootstrapModule(FdsModule, {providers: providers});
} else { //load the translation providers and bootstrap the module
var translationFile = './demo-app/messages.' + locale + '.xlf';
$.ajax({
url: translationFile
}).done(function (translations) {
// add providers if translation file for locale is loaded
if (translations) {
providers.push({provide: ngCore.TRANSLATIONS, useValue: translations});
providers.push({provide: ngCore.TRANSLATIONS_FORMAT, useValue: 'xlf'});
providers.push({provide: ngCore.LOCALE_ID, useValue: locale});
}
ngPlatformBrowserDynamic.platformBrowserDynamic().bootstrapModule(FdsModule, {providers: providers});
}).fail(function () {
ngPlatformBrowserDynamic.platformBrowserDynamic().bootstrapModule(FdsModule, {providers: providers});
});
}