Esempio n. 1
0
        /// <summary>
        /// Gets the string from the specified resource file with the current culture.
        /// </summary>
        /// <param name="languageSource">The language source.</param>
        /// <param name="resourceName">Name of the resource.</param>
        /// <param name="cultureInfo">The culture information.</param>
        /// <returns>The string or <c>null</c> if the string cannot be found.</returns>
        protected override string GetString(ILanguageSource languageSource, string resourceName, CultureInfo cultureInfo)
        {
            var source = languageSource.GetSource();

            throw new MustBeImplementedException();

            //return null;
        }
Esempio n. 2
0
        /// <summary>
        /// Gets the string from the specified resource file with the current culture.
        /// </summary>
        /// <param name="languageSource">The language source.</param>
        /// <param name="resourceName">Name of the resource.</param>
        /// <param name="cultureInfo">The culture information.</param>
        /// <returns>The string or <c>null</c> if the string cannot be found.</returns>
        protected override string GetString(ILanguageSource languageSource, string resourceName, CultureInfo cultureInfo)
        {
            var source = languageSource.GetSource();
            
            throw new MustBeImplementedException();

            //return null;
        }   
Esempio n. 3
0
        /// <summary>
        /// Gets the string from the specified resource file with the current culture.
        /// </summary>
        /// <param name="languageSource">The language source.</param>
        /// <param name="resourceName">Name of the resource.</param>
        /// <param name="cultureInfo">The culture information.</param>
        /// <returns>The string or <c>null</c> if the string cannot be found.</returns>
        protected virtual string GetString(ILanguageSource languageSource, string resourceName, CultureInfo cultureInfo)
        {
            var source         = languageSource.GetSource();
            var resourceLoader = GetResourceManager(source);

#if NETFX_CORE
            return(resourceLoader.GetString(resourceName));
#else
            return(resourceLoader.GetString(resourceName, cultureInfo));
#endif
        }
Esempio n. 4
0
        /// <summary>
        /// Gets the string from the specified resource file with the current culture.
        /// </summary>
        /// <param name="languageSource">The language source.</param>
        /// <param name="resourceName">Name of the resource.</param>
        /// <param name="cultureInfo">The culture information.</param>
        /// <returns>The string or <c>null</c> if the string cannot be found.</returns>
        /// <exception cref="ArgumentNullException">The <paramref name="languageSource" /> is <c>null</c>.</exception>
        /// <exception cref="ArgumentException">The <paramref name="resourceName" /> is <c>null</c>.</exception>
        /// <exception cref="ArgumentNullException">The <paramref name="cultureInfo" /> is <c>null</c>.</exception>
        public override string GetString(ILanguageSource languageSource, string resourceName, CultureInfo cultureInfo)
        {
            Argument.IsNotNull("languageSource", languageSource);
            Argument.IsNotNullOrWhitespace("resourceName", resourceName);
            Argument.IsNotNull("cultureInfo", cultureInfo);

            var source = languageSource.GetSource();
            
            throw new MustBeImplementedException();

            //return null;
        }   
Esempio n. 5
0
        /// <summary>
        /// Gets the string from the specified resource file with the current culture.
        /// </summary>
        /// <param name="languageSource">The language source.</param>
        /// <param name="resourceName">Name of the resource.</param>
        /// <param name="cultureInfo">The culture information.</param>
        /// <returns>The string or <c>null</c> if the string cannot be found.</returns>
        /// <exception cref="ArgumentNullException">The <paramref name="languageSource" /> is <c>null</c>.</exception>
        /// <exception cref="ArgumentException">The <paramref name="resourceName" /> is <c>null</c>.</exception>
        /// <exception cref="ArgumentNullException">The <paramref name="cultureInfo" /> is <c>null</c>.</exception>
        public override string GetString(ILanguageSource languageSource, string resourceName, CultureInfo cultureInfo)
        {
            Argument.IsNotNull("languageSource", languageSource);
            Argument.IsNotNullOrWhitespace("resourceName", resourceName);
            Argument.IsNotNull("cultureInfo", cultureInfo);

            var source = languageSource.GetSource();

            throw new MustBeImplementedException();

            //return null;
        }
Esempio n. 6
0
        /// <summary>
        /// Gets the string from the specified resource file with the current culture.
        /// </summary>
        /// <param name="languageSource">The language source.</param>
        /// <param name="resourceName">Name of the resource.</param>
        /// <param name="cultureInfo">The culture information.</param>
        /// <returns>The string or <c>null</c> if the string cannot be found.</returns>
        protected override string GetString(ILanguageSource languageSource, string resourceName, CultureInfo cultureInfo)
        {
            var source         = languageSource.GetSource();
            var resourceLoader = GetResourceManager(source);

            if (resourceLoader != null)
            {
#if NETFX_CORE
                return(resourceLoader.GetString(resourceName));
#else
                return(resourceLoader.GetString(resourceName, cultureInfo));
#endif
            }

            return(null);
        }
Esempio n. 7
0
        /// <summary>
        /// Gets the string from the specified resource file with the current culture.
        /// </summary>
        /// <param name="languageSource">The language source.</param>
        /// <param name="resourceName">Name of the resource.</param>
        /// <param name="cultureInfo">The culture information.</param>
        /// <returns>The string or <c>null</c> if the string cannot be found.</returns>
        protected override string GetString(ILanguageSource languageSource, string resourceName, CultureInfo cultureInfo)
        {
            var source = languageSource.GetSource();
            var resourceLoader = GetResourceManager(source);

            if (resourceLoader != null)
            {
#if NETFX_CORE
                return resourceLoader.GetString(resourceName);
#else
                return resourceLoader.GetString(resourceName, cultureInfo);
#endif
            }

            return null;
        }
Esempio n. 8
0
        /// <summary>
        /// Gets the string from the specified resource file with the current culture.
        /// </summary>
        /// <param name="languageSource">The language source.</param>
        /// <param name="resourceName">Name of the resource.</param>
        /// <param name="cultureInfo">The culture information.</param>
        /// <returns>The string or <c>null</c> if the string cannot be found.</returns>
        protected override string GetString(ILanguageSource languageSource, string resourceName, CultureInfo cultureInfo)
        {
            string value          = null;
            var    source         = languageSource.GetSource();
            var    resourceLoader = GetResourceManager(source);

            if (resourceLoader != null)
            {
#if NETFX_CORE
                var resourceContainer = GetResourceContainer(source);

                // Try the language specific first
                var neutralSource          = string.Format("{0}", resourceContainer);
                var languageSpecificSource = string.Format("{0}.{1}", resourceContainer, cultureInfo.Name);

                var currentResourceManager = Windows.ApplicationModel.Resources.Core.ResourceManager.Current;

                var finalResourceMap = (from resourceMap in currentResourceManager.AllResourceMaps
                                        where resourceMap.Value.GetSubtree(languageSpecificSource) != null
                                        select resourceMap.Value.GetSubtree(languageSpecificSource)).FirstOrDefault();

                if (finalResourceMap == null)
                {
                    finalResourceMap = (from resourceMap in currentResourceManager.AllResourceMaps
                                        where resourceMap.Value.GetSubtree(neutralSource) != null
                                        select resourceMap.Value.GetSubtree(neutralSource)).FirstOrDefault();
                }

                if (finalResourceMap != null)
                {
                    var resourceContext = ResourceContext.GetForViewIndependentUse();
                    resourceContext.Languages = new[] { cultureInfo.Name };

                    var resourceCandidate = finalResourceMap.GetValue(resourceName, resourceContext);
                    if (resourceCandidate != null)
                    {
                        value = resourceCandidate.ValueAsString;
                    }
                }
#else
                value = resourceLoader.GetString(resourceName, cultureInfo);
#endif
            }

            return(value);
        }
        /// <summary>
        /// Gets the string from the specified resource file with the current culture.
        /// </summary>
        /// <param name="languageSource">The language source.</param>
        /// <param name="resourceName">Name of the resource.</param>
        /// <param name="cultureInfo">The culture information.</param>
        /// <returns>The string or <c>null</c> if the string cannot be found.</returns>
        protected override string GetString(ILanguageSource languageSource, string resourceName, CultureInfo cultureInfo)
        {
            string value = null;
            var source = languageSource.GetSource();
            var resourceLoader = GetResourceManager(source);

            if (resourceLoader != null)
            {
#if NETFX_CORE
                var resourceContainer = GetResourceContainer(source);

                // Try the language specific first
                var neutralSource = string.Format("{0}", resourceContainer);
                var languageSpecificSource = string.Format("{0}.{1}", resourceContainer, cultureInfo.Name);

                var currentResourceManager = Windows.ApplicationModel.Resources.Core.ResourceManager.Current;

                var finalResourceMap = (from resourceMap in currentResourceManager.AllResourceMaps
                                        where resourceMap.Value.GetSubtree(languageSpecificSource) != null
                                        select resourceMap.Value.GetSubtree(languageSpecificSource)).FirstOrDefault();

                if (finalResourceMap == null)
                {
                    finalResourceMap = (from resourceMap in currentResourceManager.AllResourceMaps
                                        where resourceMap.Value.GetSubtree(neutralSource) != null
                                        select resourceMap.Value.GetSubtree(neutralSource)).FirstOrDefault();
                }

                if (finalResourceMap != null)
                {
                    var resourceContext = ResourceContext.GetForViewIndependentUse();
                    resourceContext.Languages = new[] { cultureInfo.Name };

                    var resourceCandidate = finalResourceMap.GetValue(resourceName, resourceContext);
                    if (resourceCandidate != null)
                    {
                        value = resourceCandidate.ValueAsString;
                    }
                }
#else
                value = resourceLoader.GetString(resourceName, cultureInfo);
#endif
            }

            return value;
        }
Esempio n. 10
0
 /// <summary>
 /// Preloads the language sources to provide optimal performance.
 /// </summary>
 /// <param name="languageSource">The language source.</param>
 protected override void PreloadLanguageSource(ILanguageSource languageSource)
 {
     GetResourceManager(languageSource.GetSource());
 }
Esempio n. 11
0
 /// <summary>
 /// Preloads the language sources to provide optimal performance.
 /// </summary>
 /// <param name="languageSource">The language source.</param>    
 protected override void PreloadLanguageSource(ILanguageSource languageSource)
 {
     GetResourceManager(languageSource.GetSource());
 }
Esempio n. 12
0
        /// <summary>
        /// Gets the string from the specified resource file with the current culture.
        /// </summary>
        /// <param name="languageSource">The language source.</param>
        /// <param name="resourceName">Name of the resource.</param>
        /// <param name="cultureInfo">The culture information.</param>
        /// <returns>The string or <c>null</c> if the string cannot be found.</returns>
        /// <exception cref="ArgumentNullException">The <paramref name="languageSource" /> is <c>null</c>.</exception>
        /// <exception cref="ArgumentException">The <paramref name="resourceName" /> is <c>null</c>.</exception>
        /// <exception cref="ArgumentNullException">The <paramref name="cultureInfo" /> is <c>null</c>.</exception>
        public override string GetString(ILanguageSource languageSource, string resourceName, CultureInfo cultureInfo)
        {
            Argument.IsNotNull("languageSource", languageSource);
            Argument.IsNotNullOrWhitespace("resourceName", resourceName);
            Argument.IsNotNull("cultureInfo", cultureInfo);

            string value          = null;
            var    source         = languageSource.GetSource();
            var    resourceLoader = GetResourceManager(source);

            if (resourceLoader != null)
            {
#if NETFX_CORE
                var resourceContainer = GetResourceContainer(source);

                // Try the language specific first
                var neutralSource          = string.Format("{0}", resourceContainer);
                var cultureName            = cultureInfo.Name;
                var languageSpecificSource = string.Format("{0}.{1}", resourceContainer, cultureName);

                var currentResourceManager = Windows.ApplicationModel.Resources.Core.ResourceManager.Current;

                var finalResourceMap = (from resourceMap in currentResourceManager.AllResourceMaps
                                        let rm = resourceMap.Value.GetSubtree(languageSpecificSource)
                                                 where rm != null
                                                 select rm).FirstOrDefault();

                if ((finalResourceMap == null) && !cultureInfo.IsNeutralCulture)
                {
                    cultureName            = cultureInfo.Parent.Name;
                    languageSpecificSource = string.Format("{0}.{1}", resourceContainer, cultureName);

                    finalResourceMap = (from resourceMap in currentResourceManager.AllResourceMaps
                                        let rm = resourceMap.Value.GetSubtree(languageSpecificSource)
                                                 where rm != null
                                                 select rm).FirstOrDefault();
                }

                if (finalResourceMap == null)
                {
                    finalResourceMap = (from resourceMap in currentResourceManager.AllResourceMaps
                                        let rm = resourceMap.Value.GetSubtree(neutralSource)
                                                 where rm != null
                                                 select rm).FirstOrDefault();
                }

                if (finalResourceMap != null)
                {
                    var resourceContext = ResourceContext.GetForViewIndependentUse();
                    resourceContext.Languages = new[] { cultureName };

                    var resourceCandidate = finalResourceMap.GetValue(resourceName, resourceContext);
                    if (resourceCandidate != null)
                    {
                        value = resourceCandidate.ValueAsString;
                    }
                }
#else
                value = resourceLoader.GetString(resourceName, cultureInfo);
#endif
            }

            return(value);
        }
Esempio n. 13
0
        /// <summary>
        /// Gets the string from the specified resource file with the current culture.
        /// </summary>
        /// <param name="languageSource">The language source.</param>
        /// <param name="resourceName">Name of the resource.</param>
        /// <param name="cultureInfo">The culture information.</param>
        /// <returns>The string or <c>null</c> if the string cannot be found.</returns>
        protected virtual string GetString(ILanguageSource languageSource, string resourceName, CultureInfo cultureInfo)
        {
            var source = languageSource.GetSource();
            var resourceLoader = GetResourceManager(source);

#if NETFX_CORE
            return resourceLoader.GetString(resourceName);
#else
            return resourceLoader.GetString(resourceName, cultureInfo);
#endif
        }
Esempio n. 14
0
        /// <summary>
        /// Gets the string from the specified resource file with the current culture.
        /// </summary>
        /// <param name="languageSource">The language source.</param>
        /// <param name="resourceName">Name of the resource.</param>
        /// <param name="cultureInfo">The culture information.</param>
        /// <returns>The string or <c>null</c> if the string cannot be found.</returns>
        /// <exception cref="ArgumentNullException">The <paramref name="languageSource" /> is <c>null</c>.</exception>
        /// <exception cref="ArgumentException">The <paramref name="resourceName" /> is <c>null</c>.</exception>
        /// <exception cref="ArgumentNullException">The <paramref name="cultureInfo" /> is <c>null</c>.</exception>
        public override string GetString(ILanguageSource languageSource, string resourceName, CultureInfo cultureInfo)
        {
            Argument.IsNotNull("languageSource", languageSource);
            Argument.IsNotNullOrWhitespace("resourceName", resourceName);
            Argument.IsNotNull("cultureInfo", cultureInfo);
            
            string value = null;
            var source = languageSource.GetSource();
            var resourceLoader = GetResourceManager(source);

            if (resourceLoader != null)
            {
#if NETFX_CORE
                var resourceContainer = GetResourceContainer(source);

                // Try the language specific first
                var neutralSource = string.Format("{0}", resourceContainer);
                var cultureName = cultureInfo.Name;
                var languageSpecificSource = string.Format("{0}.{1}", resourceContainer, cultureName);

                var currentResourceManager = Windows.ApplicationModel.Resources.Core.ResourceManager.Current;

                var finalResourceMap = (from resourceMap in currentResourceManager.AllResourceMaps
                                        let rm = resourceMap.Value.GetSubtree(languageSpecificSource)
                                        where rm != null
                                        select rm).FirstOrDefault();

                if ((finalResourceMap == null) && !cultureInfo.IsNeutralCulture)
                {
                    cultureName = cultureInfo.Parent.Name;
                    languageSpecificSource = string.Format("{0}.{1}", resourceContainer, cultureName);

                    finalResourceMap = (from resourceMap in currentResourceManager.AllResourceMaps
                                        let rm = resourceMap.Value.GetSubtree(languageSpecificSource)
                                        where rm != null
                                        select rm).FirstOrDefault();
                }

                if (finalResourceMap == null)
                {
                    finalResourceMap = (from resourceMap in currentResourceManager.AllResourceMaps
                                        let rm = resourceMap.Value.GetSubtree(neutralSource)
                                        where rm != null
                                        select rm).FirstOrDefault();
                }

                if (finalResourceMap != null)
                {
                    var resourceContext = ResourceContext.GetForViewIndependentUse();
                    resourceContext.Languages = new[] { cultureName };

                    var resourceCandidate = finalResourceMap.GetValue(resourceName, resourceContext);
                    if (resourceCandidate != null)
                    {
                        value = resourceCandidate.ValueAsString;
                    }
                }
#else
                value = resourceLoader.GetString(resourceName, cultureInfo);
#endif
            }

            return value;
        }