mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
Making the translation keys cas insensitive, and making generic keys explicit
--HG-- branch : dev
This commit is contained in:
@@ -47,12 +47,13 @@ namespace Orchard.Localization.Services {
|
|||||||
|
|
||||||
foreach (var culture in cultures) {
|
foreach (var culture in cultures) {
|
||||||
if (String.Equals(cultureName, culture.CultureName, StringComparison.OrdinalIgnoreCase)) {
|
if (String.Equals(cultureName, culture.CultureName, StringComparison.OrdinalIgnoreCase)) {
|
||||||
string scopedKey = scope + "|" + text;
|
string scopedKey = (scope + "|" + text).ToLowerInvariant();
|
||||||
string genericKey = "|" + text;
|
|
||||||
if (culture.Translations.ContainsKey(scopedKey)) {
|
if (culture.Translations.ContainsKey(scopedKey)) {
|
||||||
return culture.Translations[scopedKey];
|
return culture.Translations[scopedKey];
|
||||||
}
|
}
|
||||||
if (culture.Translations.ContainsKey(genericKey)) {
|
|
||||||
|
string genericKey = ("|" + text).ToLowerInvariant();
|
||||||
|
if ( culture.Translations.ContainsKey(genericKey) ) {
|
||||||
return culture.Translations[genericKey];
|
return culture.Translations[genericKey];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -64,8 +65,8 @@ namespace Orchard.Localization.Services {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static string GetParentTranslation(string scope, string text, string cultureName, IEnumerable<CultureDictionary> cultures) {
|
private static string GetParentTranslation(string scope, string text, string cultureName, IEnumerable<CultureDictionary> cultures) {
|
||||||
string scopedKey = scope + "|" + text;
|
string scopedKey = (scope + "|" + text).ToLowerInvariant();
|
||||||
string genericKey = "|" + text;
|
string genericKey = ("|" + text).ToLowerInvariant();
|
||||||
try {
|
try {
|
||||||
CultureInfo cultureInfo = CultureInfo.GetCultureInfo(cultureName);
|
CultureInfo cultureInfo = CultureInfo.GetCultureInfo(cultureName);
|
||||||
CultureInfo parentCultureInfo = cultureInfo.Parent;
|
CultureInfo parentCultureInfo = cultureInfo.Parent;
|
||||||
@@ -183,24 +184,13 @@ namespace Orchard.Localization.Services {
|
|||||||
if (poLine.StartsWith("msgstr")) {
|
if (poLine.StartsWith("msgstr")) {
|
||||||
string translation = ParseTranslation(poLine);
|
string translation = ParseTranslation(poLine);
|
||||||
if (!String.IsNullOrEmpty(id)) {
|
if (!String.IsNullOrEmpty(id)) {
|
||||||
if (!String.IsNullOrEmpty(scope)) {
|
string scopedKey = (scope + "|" + id).ToLowerInvariant();
|
||||||
string scopedKey = scope + "|" + id;
|
if (!translations.ContainsKey(scopedKey)) {
|
||||||
if (!translations.ContainsKey(scopedKey)) {
|
translations.Add(scopedKey, translation);
|
||||||
translations.Add(scopedKey, translation);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if (merge) {
|
|
||||||
translations[scopedKey] = translation;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
string genericKey = "|" + id;
|
|
||||||
if (!translations.ContainsKey(genericKey)) {
|
|
||||||
translations.Add(genericKey, translation);
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (merge) {
|
if (merge) {
|
||||||
translations[genericKey] = translation;
|
translations[scopedKey] = translation;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user