private void UpdateText() { if (identifier == "") { return; } Font font = L20n.CurrentFont; if (useCustomFonts) { Font f = null; if (fonts.GetAllResources().TryGetValue(L20n.CurrentLocale, out f)) { font = f; } else if (defaultFont != null) { font = defaultFont; } } if (useVariables) { var text = L20n.Translate(identifier, variables.GetKeys(), variables.GetValues()); SetText(text, font); } else { var text = L20n.Translate(identifier); SetText(text, font); } }
public void SetText() { var locale = L20n.CurrentLocale; var text = string.Format("{0} ({1})", L20n.Translate(locale), locale); GetComponent <Text> ().text = text; }
public void SetLocale() { var locale = L20n.Locales [(int)m_Slider.value]; L20n.SetLocale(locale); m_Text.SetText(); }
/// <summary> /// Add all the values specified in this collection to the Global Environment. /// </summary> /// <remarks> /// All values in this collection will get removed at the end of this method. /// </remarks> public void AddValuesToEnvironment() { var count = Count; for (int i = 0; i < count; ++i) { L20n.AddGlobal(keys [i], values [i].GetValue()); } keys.Clear(); values.Clear(); }
public override void Collect(L20nCore.External.InfoCollector info) { switch (m_Gender) { case Gender.Default: info.Add("gender", "default"); info.Add("name", () => L20n.Translate("neutral_user_name")); break; case Gender.Feminine: info.Add("gender", "feminine"); info.Add("name", () => L20n.Translate("feminine_user_name")); break; case Gender.Masculine: info.Add("gender", "masculine"); info.Add("name", () => L20n.Translate("masculine_user_name")); break; } }
/// <summary> /// Initialized and setups the L20n System. /// Called during the `Awake` phase. /// </summary> void Awake() { // Make sure that L20n isn't initialized yet. // This can happen as you might have used this component already in a previous scene. // Which might be quite common as this component should be used in all scenes // that you may want to start up from directly during development. if (!L20n.IsInitialized) { if (manifestPath == null) { Debug.LogError("<L20nSettings> requires the manifest to be set", this); return; } if (overrideLocale == "") { overrideLocale = null; } // Initialize L20n L20n.Initialize(uniqueGameID, manifestPath, overrideLocale); // Set the default fonts and global variables (if there are any) L20n.SetFont(L20n.DefaultLocale, defaultFont); foreach (var pair in fonts.GetAllResources()) { L20n.SetFont(pair.Key, pair.Value); } globalVariables.AddValuesToEnvironment(); } if (destroyObject) { Destroy(gameObject); } else { Destroy(this); } }
// It's important that you initialize L20n before you start localizing anything. // Doing the initialization in Awake is a good option, or simply // making sure that your initialization script is ran first is a possibility as well. void Awake() { // Make sure that L20n isn't already initialized if (!L20n.IsInitialized) { // Initialize L20n, setting the Game ID and the Manifest Path // this line is the only required method call to initialize L20n! L20n.Initialize("L20nDemo", "L20n/examples/manifest.json"); // ALL STUFF BELOW IS OPTIONAL! // Optinially you can also set the default fonts to use for Text Components L20n.SetFont("jp", m_JapaneseFont); L20n.SetFont(m_DefaultFont); // Game-Specific Globals can be added as well // These variables are avaiable for all translations L20n.AddStaticGlobal("temperature", m_Temperature); L20n.AddComplexGlobal("user", m_User); } }
/// <summary> /// Called when the button gets clicked. /// Sets the L20n locale to the one specified in this component. /// </summary> public void OnSubmit() { L20n.SetLocale(m_LocaleIdentifier); }