Example #1
0
		/* === MANAGING LOCALE DATA (TEXT MAPPINGS) === */
		
		/// <summary> Registers a resource file as a source of locale data for the specified
		/// locale.
		/// 
		/// </summary>
		/// <param name="locale">The locale of the definitions provided.
		/// </param>
		/// <param name="resource">A LocaleDataSource containing string data for the locale provided
		/// </param>
		/// <throws>  NullPointerException if resource or locale are null </throws>
		public virtual void  registerLocaleResource(System.String locale, LocaleDataSource resource)
		{
			if (locale == null)
			{
				throw new System.NullReferenceException("Attempt to register a data source to a null locale in the localizer");
			}
			if (resource == null)
			{
				throw new System.NullReferenceException("Attempt to register a null data source in the localizer");
			}
			
			List< LocaleDataSource > resources = new List< LocaleDataSource >();
			if (localeResources.containsKey(locale))
			{
				resources = localeResources.get_Renamed(locale);
			}
			resources.addElement(resource);
			localeResources.put(locale, resources);
			
			if (locale.Equals(currentLocale) || locale.Equals(defaultLocale))
			{
				loadCurrentLocaleResources();
			}
		}
Example #2
0
		/// <summary> Get text for locale and exact text ID only, not using any fallbacks.
		/// 
		/// NOTE: This call will only return the full compliment of available strings if and
		/// only if the requested locale is current. Otherwise it will only retrieve strings
		/// declared at runtime.
		/// 
		/// </summary>
		/// <param name="locale">Locale. Must be defined and not null.
		/// </param>
		/// <param name="textID">Text handle (text ID appended with optional text form). Must not be null.
		/// </param>
		/// <returns> Localized text. Return null if none found.
		/// </returns>
		/// <throws>  UnregisteredLocaleException If the locale is not defined or null. </throws>
		/// <throws>  NullPointerException if textID is null </throws>
		public virtual System.String getRawText(System.String locale, System.String textID)
		{
			if (locale == null)
			{
				throw new UnregisteredLocaleException("Null locale when attempting to fetch text id: " + textID);
			}
			if (textID == null)
			{
				throw new System.NullReferenceException("Null textId passed to localizer");
			}
			if (locale.Equals(currentLocale))
			{
				PrefixTreeNode data = currentLocaleData.get_Renamed(textID);
				return data == null?null:data.render();
			}
			else
			{
				PrefixTreeNode data = getLocaleMap(locale).get_Renamed(textID);
				return data == null?null:data.render();
			}
		}