/// <summary> /// Returns the localized resource of the given key and locale, or null /// if no localized resource is available. /// </summary> /// <param name="key"> the key of the localized resource, not null </param> /// <param name="locale"> the locale, not null </param> /// <returns> the localized resource, or null if not available </returns> /// <exception cref="NullPointerException"> if key or locale is null </exception> //JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @SuppressWarnings("unchecked") static <T> T getLocalizedResource(String key, java.util.Locale locale) internal static T getLocalizedResource <T>(String key, Locale locale) { LocaleResources lr = LocaleProviderAdapter.ResourceBundleBased.getLocaleResources(locale); ResourceBundle rb = lr.JavaTimeFormatData; return(rb.ContainsKey(key) ? (T)rb.GetObject(key) : null); }
public Object FindResource(ResourceBundle bundle, String className, String requestedKey, int index, String aliasKey, Hashtable visited_0) { if (aliasKey != null && visited_0[className + aliasKey] != null) { throw new MissingManifestResourceException("Circular Aliases in bundle."); } if (aliasKey == null) { // currently we do an implicit key lookup // return ((ICUListResourceBundle)bundle).getContents(); aliasKey = requestedKey; } ILOG.J2CsMapping.Collections.Collections.Put(visited_0, className + requestedKey, ""); String[] keys = IBM.ICU.Impl.ICUListResourceBundle.Split(aliasKey, IBM.ICU.Impl.ICUListResourceBundle.RES_PATH_SEP_CHAR); Object o = null; if (keys.Length > 0) { o = bundle.GetObject(keys[0]); o = FindResource(o, keys, 1, index); } o = ResolveAliases(o, className, aliasKey, visited_0); return(o); }
/// @draft ICU 3.2 /// @provisional This API might change or be removed in a future release. public static Holiday[] GetHolidays(ULocale locale) { Holiday[] result = noHolidays; try { ResourceBundle bundle = IBM.ICU.Util.UResourceBundle.GetBundleInstance( "com.ibm.icu.impl.data.HolidayBundle", locale); result = (Holiday[])bundle.GetObject("holidays"); } catch (MissingManifestResourceException e) { } return(result); }
/// <summary>Get a resource given bundle name and key</summary> /// <?/> /// <param name="bundleName">name of the resource bundle</param> /// <param name="key">to lookup the resource</param> /// <param name="suffix">for the key to lookup</param> /// <param name="defaultValue">of the resource</param> /// <returns>the resource or the defaultValue</returns> /// <exception cref="System.InvalidCastException">if the resource found doesn't match T /// </exception> public static T GetValue <T>(string bundleName, string key, string suffix, T defaultValue ) { lock (typeof(ResourceBundles)) { T value; try { ResourceBundle bundle = GetBundle(bundleName); value = (T)bundle.GetObject(GetLookupKey(key, suffix)); } catch (Exception) { return(defaultValue); } return(value); } }
public static ComponentOrientation GetOrientation(ResourceBundle bdl) { ComponentOrientation result = null; try { result = (ComponentOrientation)bdl.GetObject("Orientation"); } catch (Exception) { } if (result == null) { result = GetOrientation(bdl.Locale); } if (result == null) { result = GetOrientation(Locale.Default); } return(result); }