getSCurrentLan method
dynamic
getSCurrentLan(
- dynamic sourceOriginal,
- dynamic lancode
Implementation
getSCurrentLan(dynamic sourceOriginal, lancode) {
myLogAll('getSCurrentLan');
if (isNull(sourceOriginal)) {
return '';
}
dynamic source = sourceOriginal.toString().replaceAll(gSTRSEPITEM, ' ');
dynamic sourceLocase = source.toLowerCase();
//if (_i10nMap.isNotEmpty) {}
if (!isNull(_i10nMap[sourceLocase]) &&
!isNull(_i10nMap[sourceLocase][lancode])) {
return _i10nMap[sourceLocase][lancode];
}
/*dynamic sourceLocase = source0.toLowerCase();
dynamic source = sourceLocase;*/
dynamic splitS = source.split('}');
dynamic result = '';
dynamic delimiter = '';
//先按其它符号分隔,再按空格分隔
for (int i = 0; i < splitS.length; i++) {
dynamic splitSpace = splitS[i].split(' ');
for (int k = 0; k < splitSpace.length; k++) {
dynamic sourceChck = splitSpace[k].split('{');
dynamic sj = '';
for (int j = 0; j < sourceChck.length; j++) {
String sourceStr = sourceChck[j];
Characters charList = '$sourceStr,'.toLowerCase().characters;
String tmp = '';
int charListLength = charList.length;
for (int l = 0; l < charListLength; l++) {
String charL = charList.elementAt(l);
if (_letterSetLower.contains(charL)) {
tmp = '$tmp$charL';
} else {
Map tmpNode = getI10nMapValue(tmp);
if (isNull(tmpNode) || isNull(tmpNode[lancode])) {
if (!isNull(tmp)) {
String char0 = tmp.characters.elementAt(0);
String char1 = sourceStr.characters.elementAt(0);
if (char0 != char1 && char0.toUpperCase() == char1) {
tmp = '$char1${tmp.substring(1)}';
}
}
sj += tmp;
} else {
String tmpI10n = getI10nMapValue(tmp)[lancode];
if (lancode != gEn || sourceStr.isEmpty || sourceStr == tmp) {
sj += tmpI10n;
} else {
//首字母是否大写
sj += tmpI10n.substring(0, 1).toUpperCase() +
tmpI10n.substring(1);
}
}
if (l < charListLength - 1) {
sj += charL;
}
tmp = '';
}
}
if (lancode != gZh) {
//delimiter = ' ';
String char0 = charList.elementAt(0);
String char1 = '';
if (!isNull(sourceStr)) {
char1 = sourceStr.characters.elementAt(0);
}
if (char0 != char1 && char0.toUpperCase() == char1) {
sj = '$char1${sj.toString().substring(1)}';
}
}
}
result += delimiter + sj;
if (lancode != gZh) {
delimiter = ' ';
}
}
}
return result;
}