Beispiel #1
0
    public static void UpdateI18N(List <List <string> > data)
    {
        I18nData i18nFile = ScriptableObject.CreateInstance <I18nData>();

        i18nFile.name     = "I18n Data";
        i18nFile.i18nData = new List <I18nTextSave>();
        foreach (List <string> l in data)
        {
            i18nFile.i18nData.Add(
                new I18nTextSave()
            {
                key = l[0],
                fr  = l[1],
                en  = l[2]
            }
                );
        }

        if (!AssetDatabase.IsValidFolder("Assets/Resources"))
        {
            AssetDatabase.CreateFolder("Assets", "Resources");
        }
        if (!AssetDatabase.IsValidFolder("Assets/Resources/i18n"))
        {
            AssetDatabase.CreateFolder("Assets/Resources", "i18n");
        }
        AssetDatabase.CreateAsset(i18nFile, "Assets/Resources/i18n/Data.asset");

        I18N.LoadText();

        if (TextUpdated != null)
        {
            TextUpdated();
        }
    }
Beispiel #2
0
    public static void LoadText()
    {
        i18n = new Dictionary <string, I18nText>();

        I18nData data = Resources.Load <I18nData>("i18n/Data");

        if (data == null)
        {
            return;
        }

        foreach (I18nTextSave l in data.i18nData)
        {
            i18n.Add(l.key, new I18nText()
            {
                fr = l.fr, en = l.en
            });
        }
    }