/// <summary> /// Get the translation (entity) for the current locale, with the default locale as a fallback. /// This method will return the given id if it could not be translated or found. /// The given <c>parameter_values</c> will get bound with the given <c>parameter_kesy</c> as external values ($-syntax), /// and will be available during the translation of the given <c>id</c>. /// </summary> /// <remarks> /// Note that the <c>id</c> can be a simple identifier or a property-expression. /// Meaning that you can have something like `foo` but also `foo.bar` or `foo.bar.baz`. /// A property expression uses the dot `.` syntax and allows you to specify values within your /// hash-tables used as values in your Entity. The default or index will be used in case a property /// identifier couldn't be found. /// For string-values this extra property identifier will simply be ignored. /// Meaning that something like `foo.bar` would be equal to `foo`. /// </remarks> public static string Translate (string id, string parameter_key_a, IHashValue parameter_value_a, string parameter_key_b, string parameter_value_b) { var keys = new List<string> { parameter_key_a, parameter_key_b }; var values = new List<L20nObject> { new Entity (parameter_value_a), new StringOutput (parameter_value_b) }; return GetCore ().Translate (id, keys, values); }
/// <summary> /// This function should be called after the L20n Initialization, but before any translation, if possible. /// Even though it's safe to call it at any time during runtime, it is not recommended. /// Globals are available to all locales and are accessible within the L20n Language via the @-syntax. /// This function stores the given <c>value</c> as a global value with the given <c>id</c> as its name. /// </summary> public static void AddComplexGlobal (string id, IHashValue value) { GetCore ().AddGlobal (id, value); }
/// <summary> /// Add a <see cref="L20nCore.External.IHashValue"/> value with the given <c>name</c>. /// </summary> public void Add(string name, IHashValue value) { // Prepare the collector var info = External.InfoCollector.Pool.GetObject(); // Collect the given value value.Collect(info); if (m_Info.Count == 0) { Internal.Logger.Warning( "can't add an external variable that has no information exposed," + " please add information by calling `Info.Add(...)`"); return; } // Add it as a child to the current object AddObject(name, info.Collect()); info.Clear(); External.InfoCollector.Pool.ReturnObject(ref info); }