From 2719f2e52cdfe8a9fce33c80d1f8bebad455a8d9 Mon Sep 17 00:00:00 2001 From: Suha Can Date: Fri, 4 Jun 2010 11:01:34 -0700 Subject: [PATCH] - Commenting the resource manager. --HG-- branch : dev --- .../Services/DefaultResourceManager.cs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/Orchard/Localization/Services/DefaultResourceManager.cs b/src/Orchard/Localization/Services/DefaultResourceManager.cs index c85b737c1..3f0871041 100644 --- a/src/Orchard/Localization/Services/DefaultResourceManager.cs +++ b/src/Orchard/Localization/Services/DefaultResourceManager.cs @@ -32,6 +32,12 @@ namespace Orchard.Localization.Services { _shellSettings = shellSettings; } + // This will translate a string into a string in the target cultureName. + // The scope portion is optional, it amounts to the location of the file containing + // the string in case it lives in a view, or the namespace name if the string lives in a binary. + // If the culture doesn't have a translation for the string, it will fallback to the + // parent culture as defined in the .net culture hierarchy. e.g. fr-FR will fallback to fr. + // In case it's not found anywhere, the text is returned as is. public string GetLocalizedString(string scope, string text, string cultureName) { var cultures = LoadCultures(); @@ -78,6 +84,9 @@ namespace Orchard.Localization.Services { return text; } + // Loads the culture dictionaries in memory and caches them. + // Cache entry will be invalidated any time the directories hosting + // the .po files are modified. private IEnumerable LoadCultures() { return _cacheManager.Get("cultures", ctx => { var cultures = new List(); @@ -92,6 +101,16 @@ namespace Orchard.Localization.Services { } + // Merging occurs from multiple locations: + // In reverse priority order: + // "/Core/App_Data/Localization//orchard.core.po"; + // "/Modules//App_Data/Localization//orchard.module.po"; + // "/App_Data/Localization//orchard.root.po"; + // "/App_Data/Sites//Localization//orchard.po"; + // The dictionary entries from po files that live in higher priority locations will + // override the ones from lower priority locations during loading of dictionaries. + + // TODO: Add culture name in the po file name to facilitate usage. private IDictionary LoadTranslationsForCulture(string culture, AcquireContext context) { IDictionary translations = new Dictionary(); string corePath = string.Format(CoreLocalizationFilePathFormat, culture);