-
Notifications
You must be signed in to change notification settings - Fork 0
/
KTranslationEngine.js
91 lines (34 loc) · 1.26 KB
/
KTranslationEngine.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
(function(kLib) {
function KTranslationEngine(classOfElementsToTranslate)
{
var private = {};
var public = this;
private.objType = classOfElementsToTranslate;
public.possibleTranslatableClasses = {
title:objType+"-title",
description:objType+"-description",
subTitle:objType+"-sub-title"
};
public.keyNameAtribute = "keyName";
public.performTranslation = function (data)
{
var classes = public.possibleTranslatableClasses;
kLib.forEach(data,function(value){
if(value[public.keyNameAtribute])
{
throw "No "+ public.keyNameAtribute + " found in "+ JSON.stringify(value);
}
kLib.iterateObject(classes,function(k,lookUpClass){
var element = kLib.getFromClassWithDataAttribute(lookUpClass,public.keyNameAtribute,value[public.keyNameAtribute]);
// element.innerHTML = value.
})
});
}
}
kLib.initTranslationEngine = function(classOfElementsToTranslate)
{
var result = new KTranslationEngine(classOfElementsToTranslate)
return result;
}
})
(kLib)