Forum rules - please read before posting.

How to check current language

I'm setting up multiple translations for my game. I need to be able to change the font for other languages (since my main font only supports English and I don't wish to change that font) and in certain scenes I will need to swap art assets for different languages. Is there a way to detect what language is selected? 

Comments

  • Yes, the current language can be read as an integer index ('0' being the default) with:

    AC.Options.GetLanguage ()
  • I've been trying to edit the ActionTemplate script to make a new Action that detects the current language. I don't have any previous experience with scripting so I'm struggling a bit with it. This is what I have so far, if anyone can point me in the right direction that would be extremely helpful.  




    using UnityEngine;
    using System.Collections;

    #if UNITY_EDITOR
    using UnityEditor;
    #endif

    namespace AC
    {

    [System.Serializable]
    public class ActionLanguage : ActionCheck
    {

    // Declare variables here
    public list currentLanguage;
    public bool trueOrFalse;

    public ActionLanguage ()
    {
    this.isDisplayed = true;
    category = ActionCategory.Custom;
    title = "Chek Language";
    description = "Checks which Lenguage is currently set.";
    }


    override public float Run ()
    {

    if (!isRunning)
    {
    isRunning = true;
    return defaultPauseTime;
    }
    else
    {
    isRunning = false;
    return 0f;
    }
    }


    #if UNITY_EDITOR

    override public void ShowGUI ()
    {
    // Action-specific Inspector GUI code here
    currentLanguage = EditorGUILayout.LabelField ("If current language is:", currentLanguage, AC.Options.GetLanguage(), true);
    trueOrFalse = EditorGUILayout.Equals ("Equals:", trueOrFalse);

    AfterRunningOption ();
    }


    public override string SetLabel ()
    {
    // Return a string used to describe the specific action's job.
    if (currentLanguage)
    {
    return ("(" + currentLanguage.name + " - " + trueOrFalse.ToString()+")");
    }
    return "";
    string labelAdd = "";
    return labelAdd;
    }

    #endif

    }

    }
  • This isn't a forum for teaching how to code, and it's easier for me to just correct it for you.  Try this.
  • Oh, nice, this sounds like it might be useful. I'm foing to keep a copy. Maybe I should put it in the wikia too. heh.
  • Sorry, Chris! I'll seek coding help elsewhere in the future. Thank you for the correction! I appreciate that. 
  • @alverik: Hi, I'm jumping on this bandwagon a bit late, but I think this script would be immensely useful for me... but Chris's link is now expired. Any chance it's saved somewhere? Trying to find it on the wikia site with no luck. Thanks!
  • edited April 2017
    @minhta  Sorry, at the time I forgot to add it. After some digging around in my folders I managed to find it. You can find the code and explanation in here.
  • No worries. Thanks so much for sharing it now! It's a big help.  :-bd
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.