Merge pull request #182 from d4rk694/languages

Ability to custimise all the texts
This commit is contained in:
Amauri CHAMPEAUX 2018-07-31 10:52:32 +02:00 committed by GitHub
commit 2685a08d8d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 115 additions and 95 deletions

View File

@ -7,10 +7,13 @@ var scripts = document.getElementsByTagName('script'),
alreadyLaunch = (alreadyLaunch === undefined) ? 0 : alreadyLaunch, alreadyLaunch = (alreadyLaunch === undefined) ? 0 : alreadyLaunch,
tarteaucitronForceLanguage = (tarteaucitronForceLanguage === undefined) ? '' : tarteaucitronForceLanguage, tarteaucitronForceLanguage = (tarteaucitronForceLanguage === undefined) ? '' : tarteaucitronForceLanguage,
tarteaucitronForceExpire = (tarteaucitronForceExpire === undefined) ? '' : tarteaucitronForceExpire, tarteaucitronForceExpire = (tarteaucitronForceExpire === undefined) ? '' : tarteaucitronForceExpire,
tarteaucitronCustomText = (tarteaucitronCustomText === undefined) ? '' : tarteaucitronCustomText,
timeExipre = 31536000000, timeExipre = 31536000000,
tarteaucitronProLoadServices, tarteaucitronProLoadServices,
tarteaucitronNoAdBlocker = false; tarteaucitronNoAdBlocker = false;
var tarteaucitron = { var tarteaucitron = {
"version": 323, "version": 323,
"cdn": cdn, "cdn": cdn,
@ -209,6 +212,10 @@ var tarteaucitron = {
// Step 2: load language and services // Step 2: load language and services
tarteaucitron.addScript(pathToLang, '', function () { tarteaucitron.addScript(pathToLang, '', function () {
if(tarteaucitronCustomText !== ''){
tarteaucitron.lang = tarteaucitron.AddOrUpdate(tarteaucitron.lang, tarteaucitronCustomText);
}
tarteaucitron.addScript(pathToServices, '', function () { tarteaucitron.addScript(pathToServices, '', function () {
var body = document.body, var body = document.body,
@ -1285,5 +1292,18 @@ var tarteaucitron = {
} }
tarteaucitron.cookie.number(); tarteaucitron.cookie.number();
},
"AddOrUpdate" : function(source, custom){
/**
Utility function to Add or update the fields of obj1 with the ones in obj2
*/
for(key in custom){
if(custom[key] instanceof Object){
source[key] = tarteaucitron.AddOrUpdate(source[key], custom[key]);
}else{
source[key] = custom[key];
}
}
return source;
} }
}; };