public void Name() { using (var resourceBundle = new ResourceBundle("ICUDATA-translit", "en_US")) { Assert.That(resourceBundle.Name, Is.EqualTo("en")); } }
public void TestGetTranslationsWithCompile() { var bundle = new ResourceBundle("FormatTags/test", null); Assert.That(bundle.Get("a", new CultureInfo("en-US")), Is.EqualTo("defaultA")); Assert.That(bundle.Get("a", new CultureInfo("nl-NL")), Is.EqualTo("nederlandseA")); }
private String ComputeLocalizedLevelName(Locale newLocale) { ResourceBundle rb = ResourceBundle.GetBundle(ResourceBundleName_Renamed, newLocale); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final String localizedName = rb.getString(name); String localizedName = rb.GetString(Name_Renamed); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final boolean isDefaultBundle = defaultBundle.equals(resourceBundleName); bool isDefaultBundle = DefaultBundle.Equals(ResourceBundleName_Renamed); if (!isDefaultBundle) { return(localizedName); } // This is a trick to determine whether the name has been translated // or not. If it has not been translated, we need to use Locale.ROOT // when calling toUpperCase(). //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final java.util.Locale rbLocale = rb.getLocale(); Locale rbLocale = rb.Locale; //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final java.util.Locale locale = java.util.Locale.ROOT.equals(rbLocale) || name.equals(localizedName.toUpperCase(java.util.Locale.ROOT)) ? java.util.Locale.ROOT : rbLocale; Locale locale = Locale.ROOT.Equals(rbLocale) || Name_Renamed.Equals(localizedName.ToUpperCase(Locale.ROOT)) ? Locale.ROOT : rbLocale; // ALL CAPS in a resource bundle's message indicates no translation // needed per Oracle translation guideline. To workaround this // in Oracle JDK implementation, convert the localized level name // to uppercase for compatibility reason. return(Locale.ROOT.Equals(locale) ? Name_Renamed : localizedName.ToUpperCase(locale)); }
/* * Customized deserialization. */ private void readObject(java.io.ObjectInputStream inJ)//throws IOException, ClassNotFoundException { { inJ.defaultReadObject(); byte major = inJ.readByte(); byte minor = inJ.readByte(); // only check MAJOR version if (major != MAJOR) { // logging.5=Different version - {0}.{1} throw new java.io.IOException("Different version - " + //$NON-NLS-1$ java.lang.Byte.valueOf(major) + "." + java.lang.Byte.valueOf(minor)); } int length = inJ.readInt(); if (length >= 0) { parameters = new Object[length]; for (int i = 0; i < parameters.Length; i++) { parameters[i] = inJ.readObject(); } } if (null != resourceBundleName) { try { resourceBundle = Logger.loadResourceBundle(resourceBundleName); } catch (MissingResourceException e) { // Cannot find the specified resource bundle resourceBundle = null; } } }
/** * Initializes this logger's resource bundle. * * @throws IllegalArgumentException if this logger's resource bundle already * exists and is different from the resource bundle specified. */ private void initResourceBundle(String resourceBundleName) { lock (this) { String current = this.resourceBundleName; if (current != null) { if (current.equals(resourceBundleName)) { return; } else { // logging.9=The specified resource bundle name "{0}" is // inconsistent with the existing one "{1}". throw new java.lang.IllegalArgumentException("The specified resource bundle name " + resourceBundleName + " is inconsistent with the existing one " + current); } } if (resourceBundleName != null) { this.resourceBundle = loadResourceBundle(resourceBundleName); this.resourceBundleName = resourceBundleName; } } }
public JobStep(Location location, JobType type, Placeable placeable, ResourceBundle resources = null) { Location = location; Type = type; Placeable = placeable; Resources = resources; }
private void LoadBundle(string bundleName, int prefix) { if (bundles.ContainsKey(prefix) || loadingBundles.ContainsKey(prefix)) { return; } IResourceBundle bundle; if (isEditor) { bundle = new EditorResourceBundle(prefix); } else { bundle = new ResourceBundle(prefix); } bundle.LoadBundle(bundleName); if (bundle.IsReady) { bundles.Add(prefix, bundle); } else { loadingBundles.Add(prefix, bundle); } }
public void TestGetTranslationsWithCompileWithFilePrefix() { var bundle = new ResourceBundle("test", null, new FileBasedResourceLocator("FormatTags")); Assert.That(bundle.Get("a", new CultureInfo("en-US")), Is.EqualTo("defaultA")); Assert.That(bundle.Get("a", new CultureInfo("nl-NL")), Is.EqualTo("nederlandseA")); }
/** * Retrieves a message from the World Wind message resource bundle formatted with specified arguments. The arguments * are inserted into the message via {@link java.text.MessageFormat}. * * @param property the property identifying which message to retrieve. * @param args the arguments referenced by the format string identified <code>property</code>. * * @return The requested string formatted with the arguments. * * @see java.text.MessageFormat */ public static string getMessage(string property, params object[] args) { string message; try { message = (string)ResourceBundle.getBundle(MESSAGE_BUNDLE_NAME, Locale.getDefault()).getObject(property); } catch (Exception e) { message = "Exception looking up message from bundle " + MESSAGE_BUNDLE_NAME; logger().log(Level.SEVERE, message, e); return(message); } try { // TODO: This is no longer working with more than one arg in the message string, e.g., {1} return(args == null ? message : MessageFormat.format(message, args)); } catch (ArgumentException e) { message = "Message arguments do not match format string: " + property; logger().log(Level.SEVERE, message, e); return(message); } }
public String GetString(String key, Object[] parameters) { if (defaultBundle == null) { try { defaultBundle = ResourceBundle.GetBundle(defaultBundleBaseName, locale); }catch (Exception e) { Console.WriteLine(e); } } if (replaceBundle == null && replaceBundleName != null) { replaceBundle = ResourceBundle.GetBundle(replaceBundleName, locale); } String value = null; if (replaceBundle != null) { try { value = replaceBundle.GetString(key, parameters); } catch (MissingResourceException e) { Console.WriteLine(e); if (defaultBundle != null) { value = defaultBundle.GetString(key, parameters); } } } return(value); }
public bool RefillResource(ResourceBundle putPackage) { int maxItemsToFill = GlobalConstants.MaxOfResource; // Get possible max items in stash ResourceBundle filled = maxResources.FirstOrDefault(x => x.type == putPackage.type); if (filled != null) { maxItemsToFill = filled.count; } ResourceBundle current = stash.FirstOrDefault(x => x.type == putPackage.type); if (current == null) { current = new ResourceBundle() { count = 0, type = putPackage.type, }; stash.Add(current); } // Refill resource in stash if (current.count < maxItemsToFill) { current.count += putPackage.count; return(true); } return(false); }
/* * Constructs a {@code LogRecord} object using the supplied the logging * level and message. The millis property is set to the current time. The * sequence property is set to a new unique value, allocated in increasing * order within the virtual machine. The thread ID is set to a unique value * for the current thread. All other properties are set to {@code null}. * * @param level * the logging level, may not be {@code null}. * @param msg * the raw message. * @throws NullPointerException * if {@code level} is {@code null}. */ public LogRecord(Level level, String msg) { if (null == level) { // logging.4=The 'level' parameter is null. throw new java.lang.NullPointerException("The 'level' parameter is null."); //$NON-NLS-1$ } this.level = level; this.message = msg; this.millis = java.lang.SystemJ.currentTimeMillis(); lock (typeof(LogRecord).getClass()) { this.sequenceNumber = currentSequenceNumber++; java.lang.Integer id = currentThreadId.get(); if (null == id) { this.threadID = initThreadId; currentThreadId.set(java.lang.Integer.valueOf(initThreadId++)); } else { this.threadID = id.intValue(); } } this.sourceClassName = null; this.sourceMethodName = null; this.loggerName = null; this.parameters = null; this.resourceBundle = null; this.resourceBundleName = null; this.thrown = null; }
public void TestLoad() { var bundle = new ResourceBundle("FormatTags/compiled", null); Assert.That(bundle.Prefix, Is.EqualTo("")); Assert.That(bundle.BaseName, Is.EqualTo("FormatTags/compiled")); }
public void TestGetTranslationsWithReplacementsNonUsedParametersCanBeNull() { var bundle = new ResourceBundle("FormatTags/complex", null); Assert.That(bundle.Get("twovarswithgap", new CultureInfo("en-US"), "a", null, "c"), Is.EqualTo("two a, gap, c vars")); }
public void TestGetTranslationsWithPrefix() { var bundle = new ResourceBundle("FormatTags/compiled", "pre_"); Assert.That(bundle.Get("a", new CultureInfo("en-US")), Is.EqualTo("prefixedA")); Assert.That(bundle.Get("a", new CultureInfo("nl-NL")), Is.EqualTo("aMetVoorvoegsel")); }
public bool FitsWithin(ResourceBundle b) { return( Silver <= b.Silver && Food <= b.Food ); }
// Fixes the language display of the game internal static void FixLangDisplay(MessageDirector dir) { string[] bundles = { "achieve", "exchange" }; foreach (string bundle in bundles) { MessageBundle actor = dir.GetBundle(bundle); ResourceBundle rActor = actor.GetPrivateField <ResourceBundle>("bundle"); FileInfo fActor = new FileInfo(Application.dataPath + $"/{bundle}.yaml"); using (StreamWriter writer = fActor.CreateText()) { writer.WriteLine("#====================================="); writer.WriteLine("# AUTO GENERATED FROM THE GAME"); writer.WriteLine("#====================================="); writer.WriteLine(""); foreach (string key in rActor.GetKeys()) { writer.WriteLine($"{bundle}:" + key + ": \"" + actor.Get(key).Replace("\"", "\\\"").Replace("\n", "\\n") + "\""); } } } }
/// <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); }
/* * Formats a {@code LogRecord} object into a localized string * representation. This is a convenience method for subclasses of {@code * Formatter}. * <p> * The message string is firstly localized using the {@code ResourceBundle} * object associated with the supplied {@code LogRecord}. * <p> * Notice : if message contains "{0", then java.text.MessageFormat is used. * Otherwise no formatting is performed. * * @param r * the log record to be formatted. * @return the string resulted from the formatting. */ public String formatMessage(LogRecord r) { String pattern = r.getMessage(); ResourceBundle rb = null; // try to localize the message string first if (null != (rb = r.getResourceBundle())) { try { pattern = rb.getString(pattern); } catch (Exception e) { pattern = r.getMessage(); } } if (null != pattern) { Object[] paramsJ = r.getParameters(); /* * if the message contains "{0", use java.text.MessageFormat to * format the string */ if (pattern.indexOf("{0") >= 0 && null != paramsJ && //$NON-NLS-1$ paramsJ.Length > 0) { try { pattern = java.text.MessageFormat.format(pattern, paramsJ); } catch (java.lang.IllegalArgumentException e) { pattern = r.getMessage(); } } } return(pattern); }
public IEnumerator Process(LanotaliumContext context) { if (!context.IsProjectLoaded) { yield break; } Request <AskForGuide> request = new Request <AskForGuide>(); yield return(context.UserRequest.Request(request, "Line Setting")); if (!request.Succeed) { yield break; } var result = request.Object; GuidelineResources resource = null; var resourcePath = Application.streamingAssetsPath + "/Assets/screenlineguides"; yield return(ResourceBundle.LoadFromBundle <GuidelineResources>(resourcePath, x => resource = x)); var tunerManager = context.TunerManager.gameObject; if (tunerManager == null) { yield break; } var mgr = ExternalBehaviour <GuidelineManager> .Get( "ScreenGuideManager", resource.Prefab_ScreenSpace, tunerManager, out bool hasCreated ); mgr.TunerObject = GameObject.Find("Tuner"); mgr.TunerDot_Prefab = resource.Prefab_Dot; mgr.GetComponent <Canvas>().worldCamera = GameObject.Find("LimTunerCamera").GetComponent <Camera>(); if (hasCreated) { mgr.Init(); } if (!result.Hide) { mgr.Show(); mgr.SetCounts(result.VerticalCount, result.HorizontalCount); mgr.SetColor(ColorUtil.FromInt(result.ColorR, result.ColorG, result.ColorB, result.ColorA)); } else { mgr.Hide(); } yield return(true); }
public ResourceBundle Subtract(ResourceBundle b) { var result = new ResourceBundle(this); result.Silver -= b.Silver; result.Food -= b.Food; return(result); }
public ResourceBundle Add(ResourceBundle b) { var result = new ResourceBundle(this); result.Silver += b.Silver; result.Food += b.Food; return(result); }
//returns true when bundle passed is smaller //returns false when bundle passed is larger in ANY resource public bool CompareBundle(ResourceBundle _bundle) { if (_bundle.commodity > commodity || _bundle.luxury > luxury || _bundle.wealth > wealth) { return(false); } return(true); }
public void TestGetTranslationsWithCompileFromAssembly() { var bundle = new ResourceBundle("FormatTags.embedded_test", null, new AssemblyBasedResourceLocator(GetType().Assembly, null)); Assert.That(bundle.Get("a", new CultureInfo("en-US")), Is.EqualTo("defaultA")); Assert.That(bundle.Get("a", new CultureInfo("nl-NL")), Is.EqualTo("nederlandseA")); }
void GainedResources() { ResourceBundle gainedBundle = new ResourceBundle(0, 0, 50); app.model.manager.addBundle(gainedBundle); app.Notify(GameNotification.ResultResourceChange, app.controller.manager, new ResourceBundle(2, gainedBundle.ReturnMax()), true); gameObject.SetActive(false); }
public ResourceBundle Multiply(float f) { var result = new ResourceBundle(this); result.Silver *= f; result.Food *= f; return(result); }
void AddTresure() { int rndAmount = Random.Range(0, 500); changeBundle = new ResourceBundle(rndType, rndAmount); app.Notify(GameNotification.ResultResourceChange, app.controller.manager, changeBundle, true); app.model.manager.addToResource(rndType, rndAmount); }
public void GetStringContents() { using (var resourceBundle = new ResourceBundle("ICUDATA-translit", "en_US")) { Assert.That(resourceBundle.GetStringContents(), Is.EquivalentTo(new [] { "Hex Escape", "Unicode Character", "Unicode Name", "{0,choice,0#|1#{1}|2#{1} to {2}}" })); } }
private ResourceBundleWrapper(ResourceBundle bundle_0) { this.bundle = null; this.localeID = null; this.baseName = null; this.keys = null; this.loadingStatus = -1; this.bundle = bundle_0; }
public void setResourceBundle(ResourceBundle arg0) { Instance.CallMethod("setResourceBundle", "(Ljava/util/ResourceBundle;)V", arg0); }
public void logrb(Level arg0, String arg1, String arg2, ResourceBundle arg3, String arg4, ObjectArray<IJavaObject> arg5) { Instance.CallMethod("logrb", "(Ljava/util/logging/Level;Ljava/lang/String;Ljava/lang/String;Ljava/util/ResourceBundle;Ljava/lang/String;[Ljava/lang/Object;)V", arg0, arg1, arg2, arg3, arg4, arg5); }
public void logrb(Level arg0, String arg1, String arg2, ResourceBundle arg3, String arg4, Throwable arg5) { Instance.CallMethod("logrb", "(Ljava/util/logging/Level;Ljava/lang/String;Ljava/lang/String;Ljava/util/ResourceBundle;Ljava/lang/String;Ljava/lang/Throwable;)V", arg0, arg1, arg2, arg3, arg4, arg5); }
/** * Serialization helper to setup transient resource bundle instance. * * @param in * the input stream to read the instance data from. * @throws IOException * if an IO error occurs. * @throws ClassNotFoundException * if a class is not found. */ private void readObject(java.io.ObjectInputStream inJ) { //throws IOException, ClassNotFoundException { inJ.defaultReadObject(); if (resourceBundleName != null) { try { rb = ResourceBundle.getBundle(resourceBundleName); } catch (MissingResourceException e) { rb = null; } } }
/** * Constructs an instance of {@code Level} taking the supplied name, level * value and resource bundle name. * * @param name * the name of the level. * @param level * an integer value indicating the level. * @param resourceBundleName * the name of the resource bundle to use. * @throws NullPointerException * if {@code name} is {@code null}. */ protected Level(String name, int level, String resourceBundleName) { if (name == null) { // logging.1C=The 'name' parameter is null. throw new java.lang.NullPointerException("The 'name' parameter is null."); //$NON-NLS-1$ } this.name = name; this.value = level; this.resourceBundleName = resourceBundleName; if (resourceBundleName != null) { try { rb = ResourceBundle.getBundle(resourceBundleName, Locale .getDefault(), this.GetType().getClass().getClassLoader()); } catch (MissingResourceException e) { rb = null; } } lock (levels) { levels.add(this); } }
public void Save(string fileName, ResourceBundle resourceBundle) { throw new NotImplementedException(); }
/** * Initializes this logger's resource bundle. * * @throws IllegalArgumentException if this logger's resource bundle already * exists and is different from the resource bundle specified. */ private void initResourceBundle(String resourceBundleName) { lock (this) { String current = this.resourceBundleName; if (current != null) { if (current.equals(resourceBundleName)) { return; } else { // logging.9=The specified resource bundle name "{0}" is // inconsistent with the existing one "{1}". throw new java.lang.IllegalArgumentException("The specified resource bundle name "+resourceBundleName+" is inconsistent with the existing one "+current); } } if (resourceBundleName != null) { this.resourceBundle = loadResourceBundle(resourceBundleName); this.resourceBundleName = resourceBundleName; } } }
/** * Constructs a {@code LogRecord} object using the supplied the logging * level and message. The millis property is set to the current time. The * sequence property is set to a new unique value, allocated in increasing * order within the virtual machine. The thread ID is set to a unique value * for the current thread. All other properties are set to {@code null}. * * @param level * the logging level, may not be {@code null}. * @param msg * the raw message. * @throws NullPointerException * if {@code level} is {@code null}. */ public LogRecord(Level level, String msg) { if (null == level) { // logging.4=The 'level' parameter is null. throw new java.lang.NullPointerException("The 'level' parameter is null."); //$NON-NLS-1$ } this.level = level; this.message = msg; this.millis = java.lang.SystemJ.currentTimeMillis(); lock (typeof(LogRecord).getClass()) { this.sequenceNumber = currentSequenceNumber++; java.lang.Integer id = currentThreadId.get(); if (null == id) { this.threadID = initThreadId; currentThreadId.set(java.lang.Integer.valueOf(initThreadId++)); } else { this.threadID = id.intValue(); } } this.sourceClassName = null; this.sourceMethodName = null; this.loggerName = null; this.parameters = null; this.resourceBundle = null; this.resourceBundleName = null; this.thrown = null; }
/** * Sets the resource bundle used to localize the raw message during * formatting. * * @param resourceBundle * the resource bundle to set, may be {@code null}. */ public void setResourceBundle(ResourceBundle resourceBundle) { this.resourceBundle = resourceBundle; }
/* * Customized deserialization. */ private void readObject(java.io.ObjectInputStream inJ) { //throws IOException, ClassNotFoundException { inJ.defaultReadObject(); byte major = inJ.readByte(); byte minor = inJ.readByte(); // only check MAJOR version if (major != MAJOR) { // logging.5=Different version - {0}.{1} throw new java.io.IOException("Different version - "+ //$NON-NLS-1$ java.lang.Byte.valueOf(major)+"."+ java.lang.Byte.valueOf(minor)); } int length = inJ.readInt(); if (length >= 0) { parameters = new Object[length]; for (int i = 0; i < parameters.Length; i++) { parameters[i] = inJ.readObject(); } } if (null != resourceBundleName) { try { resourceBundle = Logger.loadResourceBundle(resourceBundleName); } catch (MissingResourceException e) { // Cannot find the specified resource bundle resourceBundle = null; } } }