Bloom.BloomFileLocator.GetBestLocalizedFile C# (CSharp) Method

GetBestLocalizedFile() public static method

If there is a file sitting next to the english one with the desired language, get that path. Otherwise, returns the English path.
public static GetBestLocalizedFile ( string pathToEnglishFile ) : string
pathToEnglishFile string
return string
        public static string GetBestLocalizedFile(string pathToEnglishFile)
        {
            var pathInDesiredLanguage = pathToEnglishFile.Replace("-en.", "-" + LocalizationManager.UILanguageId + ".");
            return RobustFile.Exists(pathInDesiredLanguage) ? pathInDesiredLanguage : pathToEnglishFile;
        }

Usage Example

        /// <summary>
        /// This can be used to find the best localized file when there is only one file with the given name,
        /// and the file is part of the files distributed with Bloom (i.e., not something in a downloaded template).
        /// </summary>
        public static string GetBestLocalizableFileDistributedWithApplication(bool existenceOfEnglishVersionIsOptional, params string[] partsOfEnglishFilePath)
        {
            var englishPath = FileLocator.GetFileDistributedWithApplication(existenceOfEnglishVersionIsOptional, partsOfEnglishFilePath);

            if (!RobustFile.Exists(englishPath))
            {
                return(englishPath);                // just return whatever the original GetFileDistributedWithApplication gave. "", null, whatever it is.
            }
            return(BloomFileLocator.GetBestLocalizedFile(englishPath));
        }
All Usage Examples Of Bloom.BloomFileLocator::GetBestLocalizedFile