Пример #1
0
        public static string PathFormat(string path, out string neutralCultureName)
        {
            neutralCultureName = null;

            if (TemplateEngine.HasArguments(path))
            {
                return(path);
            }

            var extension = Path.GetExtension(path)?.ToLowerInvariant( );
            var filename  = Path.GetFileNameWithoutExtension(path);
            var culture   = Path.GetExtension(filename)?.TrimStart('.');
            var language  = (string)null;

            if (CultureValidator.IsCulture(culture))
            {
                filename = Path.GetFileNameWithoutExtension(filename);
                language = "{culture}";
            }
            else if (CultureValidator.IsLocale(culture))
            {
                filename = Path.GetFileNameWithoutExtension(filename);
                language = "{locale}";
            }
            else
            {
                culture = null;
            }

            neutralCultureName = culture;

            switch (extension)
            {
            case ".resx":
            case ".resw":
            case ".resources":
            default: return(Path.Combine(Path.GetDirectoryName(path),
                                         filename + "." + language ?? "{culture}" + extension));
            }
        }