localization - closes #17 & #16 #19

Merged
Fangh merged 13 commits from localization into main 2024-02-29 21:50:50 +00:00
8 changed files with 164 additions and 26 deletions
Showing only changes of commit b9c1d74943 - Show all commits

View File

@ -0,0 +1,25 @@
<linker>
<assembly fullname="Unity.Addressables, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null" preserve="all">
<type fullname="UnityEngine.AddressableAssets.Addressables" preserve="all" />
</assembly>
<assembly fullname="Unity.Localization, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
<type fullname="UnityEngine.Localization.Locale" preserve="all" />
<type fullname="UnityEngine.Localization.Tables.SharedTableData" preserve="all" />
<type fullname="UnityEngine.Localization.Tables.StringTable" preserve="all" />
<type fullname="UnityEngine.Localization.LocaleIdentifier" preserve="nothing" serialized="true" />
<type fullname="UnityEngine.Localization.Metadata.MetadataCollection" preserve="nothing" serialized="true" />
<type fullname="UnityEngine.Localization.Tables.DistributedUIDGenerator" preserve="nothing" serialized="true" />
<type fullname="UnityEngine.Localization.Tables.SharedTableData/SharedTableEntry" preserve="nothing" serialized="true" />
<type fullname="UnityEngine.Localization.Tables.TableEntryData" preserve="nothing" serialized="true" />
</assembly>
<assembly fullname="Unity.ResourceManager, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null" preserve="all">
<type fullname="UnityEngine.ResourceManagement.ResourceProviders.AssetBundleProvider" preserve="all" />
<type fullname="UnityEngine.ResourceManagement.ResourceProviders.BundledAssetProvider" preserve="all" />
<type fullname="UnityEngine.ResourceManagement.ResourceProviders.InstanceProvider" preserve="all" />
<type fullname="UnityEngine.ResourceManagement.ResourceProviders.LegacyResourcesProvider" preserve="all" />
<type fullname="UnityEngine.ResourceManagement.ResourceProviders.SceneProvider" preserve="all" />
</assembly>
<assembly fullname="UnityEngine.CoreModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
<type fullname="UnityEngine.Object" preserve="all" />
</assembly>
</linker>

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 1348ae8b4f67ed743a4d30604cebfa9d
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1003,6 +1003,53 @@ MonoBehaviour:
m_EffectColor: {r: 0, g: 0, b: 0, a: 0.5} m_EffectColor: {r: 0, g: 0, b: 0, a: 0.5}
m_EffectDistance: {x: 10, y: -10} m_EffectDistance: {x: 10, y: -10}
m_UseGraphicAlpha: 1 m_UseGraphicAlpha: 1
--- !u!1 &189589442
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 189589443}
- component: {fileID: 189589444}
m_Layer: 0
m_Name: LanguageManager
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &189589443
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 189589442}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 375256414}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &189589444
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 189589442}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 4ad1b9d8a84226c48a6c2eae78cc0191, type: 3}
m_Name:
m_EditorClassIdentifier:
currentStringTable:
m_TableReference:
m_TableCollectionName: GUID:9a6eec81bdcf2bb48b63d1f03a258bde
--- !u!1 &190388868 --- !u!1 &190388868
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -2155,7 +2202,6 @@ MonoBehaviour:
votingPage: {fileID: 1660260835} votingPage: {fileID: 1660260835}
scoringPage: {fileID: 581333955} scoringPage: {fileID: 581333955}
promptList: {fileID: 11400000, guid: 21907abc84e40403ca34c4fb9ab30b06, type: 2} promptList: {fileID: 11400000, guid: 21907abc84e40403ca34c4fb9ab30b06, type: 2}
stringTableCollection: {fileID: 11400000, guid: 3d4b6573839c0274ca08f4bf9dedeca2, type: 2}
--- !u!114 &375256413 --- !u!114 &375256413
MonoBehaviour: MonoBehaviour:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -2183,6 +2229,7 @@ Transform:
m_Children: m_Children:
- {fileID: 1277491650} - {fileID: 1277491650}
- {fileID: 1937957482} - {fileID: 1937957482}
- {fileID: 189589443}
m_Father: {fileID: 0} m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &375256415 --- !u!114 &375256415

View File

@ -198,6 +198,53 @@ CanvasRenderer:
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 33958867} m_GameObject: {fileID: 33958867}
m_CullTransparentMesh: 1 m_CullTransparentMesh: 1
--- !u!1 &89490415
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 89490416}
- component: {fileID: 89490417}
m_Layer: 0
m_Name: LanguageManager
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &89490416
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 89490415}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 429358650}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &89490417
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 89490415}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 4ad1b9d8a84226c48a6c2eae78cc0191, type: 3}
m_Name:
m_EditorClassIdentifier:
currentStringTable:
m_TableReference:
m_TableCollectionName: GUID:9a6eec81bdcf2bb48b63d1f03a258bde
--- !u!1 &105416810 --- !u!1 &105416810
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -971,6 +1018,7 @@ Transform:
m_Children: m_Children:
- {fileID: 665178701} - {fileID: 665178701}
- {fileID: 993463148} - {fileID: 993463148}
- {fileID: 89490416}
m_Father: {fileID: 0} m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &429358652 --- !u!114 &429358652
@ -1003,7 +1051,6 @@ MonoBehaviour:
id: id:
creationDate: 0 creationDate: 0
explanationTime: 4 explanationTime: 4
stringTableCollection: {fileID: 11400000, guid: 3d4b6573839c0274ca08f4bf9dedeca2, type: 2}
roomCodeField: {fileID: 2023851070} roomCodeField: {fileID: 2023851070}
roomError: {fileID: 991600093} roomError: {fileID: 991600093}
playerNameField: {fileID: 1163479463} playerNameField: {fileID: 1163479463}

View File

@ -7,10 +7,7 @@
using Newtonsoft.Json; using Newtonsoft.Json;
using TMPro; using TMPro;
using Unity.VisualScripting; using Unity.VisualScripting;
using UnityEditor.Localization;
using UnityEngine; using UnityEngine;
using UnityEngine.Localization.Settings;
using UnityEngine.Localization.Tables;
using UnityEngine.UI; using UnityEngine.UI;
/// <summary> /// <summary>
@ -25,7 +22,6 @@ public class GameManager : MonoBehaviour
[Header("Other component")] [Header("Other component")]
public float explanationTime = 4f; public float explanationTime = 4f;
public StringTableCollection stringTableCollection;
[Header("Home Connection Component")] [Header("Home Connection Component")]
public TMP_InputField roomCodeField; public TMP_InputField roomCodeField;
@ -66,11 +62,6 @@ public class GameManager : MonoBehaviour
private DatabaseReference myOnlineRoom; private DatabaseReference myOnlineRoom;
private DateTime endOfViewDate = DateTime.MinValue; private DateTime endOfViewDate = DateTime.MinValue;
/// <summary>
/// Contains all the translated string for the UI
/// </summary>
private StringTable stringTable;
private void Awake() private void Awake()
{ {
submitNewPlayer.interactable = false; submitNewPlayer.interactable = false;
@ -81,7 +72,6 @@ private void Awake()
private void Start() private void Start()
{ {
InitializeHomePage(); InitializeHomePage();
stringTable = stringTableCollection.GetTable(LocalizationSettings.SelectedLocale.Identifier) as StringTable;
} }
private void InitializeHomePage() private void InitializeHomePage()
@ -179,7 +169,7 @@ public void PlayerValidateNameAndServerRoom(string _name, string _code)
{ {
Debug.LogError("Player name is empty", this); Debug.LogError("Player name is empty", this);
string errorText = stringTable.GetEntry("PhoneView/Canvas/Background/HomeState/NameField/ErrorNameLabel").LocalizedValue; string errorText = LanguageManager.Instance.currentStringTable.GetTable().GetEntry("PhoneView/Canvas/Background/HomeState/NameField/ErrorNameLabel").LocalizedValue;
nameError.text = errorText; nameError.text = errorText;
nameError.gameObject.SetActive(true); nameError.gameObject.SetActive(true);
submitNewPlayer.interactable = true; submitNewPlayer.interactable = true;
@ -191,7 +181,7 @@ public void PlayerValidateNameAndServerRoom(string _name, string _code)
{ {
Debug.LogError("Room code is empty", this); Debug.LogError("Room code is empty", this);
string errorText = stringTable.GetEntry("PhoneView/Canvas/Background/HomeState/NameField/EmptyRoom").LocalizedValue; string errorText = LanguageManager.Instance.currentStringTable.GetTable().GetEntry("PhoneView/Canvas/Background/HomeState/NameField/EmptyRoom").LocalizedValue;
roomError.text = errorText; roomError.text = errorText;
roomError.gameObject.SetActive(true); roomError.gameObject.SetActive(true);
submitNewPlayer.interactable = true; submitNewPlayer.interactable = true;
@ -209,7 +199,7 @@ public void PlayerValidateNameAndServerRoom(string _name, string _code)
if (room == null) if (room == null)
{ {
Debug.LogError("The room doesn't exists"); Debug.LogError("The room doesn't exists");
string errorText = stringTable.GetEntry("PhoneView/Canvas/Background/HomeState/NameField/ErrorRoom").LocalizedValue; string errorText = LanguageManager.Instance.currentStringTable.GetTable().GetEntry("PhoneView/Canvas/Background/HomeState/NameField/ErrorRoom").LocalizedValue;
roomError.text = errorText; roomError.text = errorText;
roomError.gameObject.SetActive(true); roomError.gameObject.SetActive(true);
submitNewPlayer.interactable = true; submitNewPlayer.interactable = true;

View File

@ -0,0 +1,21 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Localization;
using UnityEngine.Localization.Settings;
using UnityEngine.Localization.Tables;
public class LanguageManager : MonoBehaviour
{
public static LanguageManager Instance;
/// <summary>
/// Contains all the translated string for the UI
/// </summary>
public LocalizedStringTable currentStringTable;
private void Awake()
{
Instance = this;
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 4ad1b9d8a84226c48a6c2eae78cc0191
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -7,11 +7,8 @@
using Newtonsoft.Json; using Newtonsoft.Json;
using System.Linq; using System.Linq;
using System.Collections; using System.Collections;
using UnityEditor.Localization;
using UnityEngine.Localization.Settings; using UnityEngine.Localization.Settings;
using UnityEngine.Localization;
using UnityEngine.Localization.Tables; using UnityEngine.Localization.Tables;
using Google.MiniJSON;
/// <summary> /// <summary>
/// This is the game state manager on the PC side /// This is the game state manager on the PC side
@ -47,12 +44,6 @@ public class RoomManager : MonoBehaviour
[Header("Other")] [Header("Other")]
public PromptList promptList; public PromptList promptList;
public StringTableCollection stringTableCollection;
/// <summary>
/// Contains all the translated string for the UI
/// </summary>
private StringTable stringTable;
public Room myRoom { get; private set; } = null; public Room myRoom { get; private set; } = null;
@ -66,7 +57,6 @@ private void Awake()
{ {
Instance = this; Instance = this;
FirebaseInitializer.Instance.onFirebaseReady += Initialize; FirebaseInitializer.Instance.onFirebaseReady += Initialize;
stringTable = stringTableCollection.GetTable(LocalizationSettings.SelectedLocale.Identifier) as StringTable;
} }
private void Start() private void Start()
@ -213,7 +203,7 @@ private void SendRoomState(GameState _newState)
private void ResetAllPlayerLabels() private void ResetAllPlayerLabels()
{ {
string label = stringTable.GetEntry("ComputerView/Canvas/WaitingForPlayersPage/WaitingForP").LocalizedValue; string label = LanguageManager.Instance.currentStringTable.GetTable().GetEntry("ComputerView/Canvas/WaitingForPlayersPage/WaitingForP").LocalizedValue;
for (int i = 0; i < playerStickers.Count; i++) for (int i = 0; i < playerStickers.Count; i++)
{ {
playerStickers[i].Initialize($"{label}{i + 1}", i); playerStickers[i].Initialize($"{label}{i + 1}", i);