├── .gitignore ├── Documentation ├── language.gif └── unittests.png ├── LICENSE ├── README.md └── Unity Project ├── .vscode └── settings.json ├── Assets ├── Examples.meta ├── Examples │ ├── Language.meta │ └── Language │ │ ├── LanguageButtons.cs │ │ ├── LanguageButtons.cs.meta │ │ ├── LanguageTimeParameter.cs │ │ ├── LanguageTimeParameter.cs.meta │ │ ├── Resources.meta │ │ ├── Resources │ │ ├── Languages.meta │ │ └── Languages │ │ │ ├── English.txt │ │ │ ├── English.txt.meta │ │ │ ├── French.txt │ │ │ ├── French.txt.meta │ │ │ ├── German.txt │ │ │ ├── German.txt.meta │ │ │ ├── Swedish.txt │ │ │ └── Swedish.txt.meta │ │ ├── language_example.unity │ │ └── language_example.unity.meta ├── Plugins.meta └── Plugins │ ├── Farrokh Games.meta │ └── Farrokh Games │ ├── Language.meta │ └── Language │ ├── AutoLanguageBehaviour.cs │ ├── AutoLanguageBehaviour.cs.meta │ ├── Editor.meta │ ├── Editor │ ├── Tests.meta │ └── Tests │ │ ├── LanguageContainerTests.cs │ │ ├── LanguageContainerTests.cs.meta │ │ ├── LanguageManagerTests.cs │ │ └── LanguageManagerTests.cs.meta │ ├── Language.cs │ ├── Language.cs.meta │ ├── LanguageContainer.cs │ ├── LanguageContainer.cs.meta │ ├── LanguageManager.cs │ └── LanguageManager.cs.meta ├── ProjectSettings ├── AudioManager.asset ├── ClusterInputManager.asset ├── DynamicsManager.asset ├── EditorBuildSettings.asset ├── GraphicsSettings.asset ├── InputManager.asset ├── NavMeshAreas.asset ├── NetworkManager.asset ├── Physics2DSettings.asset ├── ProjectSettings.asset ├── ProjectVersion.txt ├── QualitySettings.asset ├── TagManager.asset ├── TimeManager.asset ├── UnityConnectSettings.asset └── editorsettings.asset └── UnityPackageManager └── manifest.json /.gitignore: -------------------------------------------------------------------------------- 1 | # =============== # 2 | # Unity generated # 3 | # =============== # 4 | Temp/ 5 | Obj/ 6 | UnityGenerated/ 7 | Library/ 8 | Unity Project/Temp/ 9 | Unity Project/Obj/ 10 | Unity Project/UnityGenerated/ 11 | Unity Project/Library/ 12 | 13 | # ===================================== # 14 | # Visual Studio / MonoDevelop generated # 15 | # ===================================== # 16 | ExportedObj/ 17 | *.svd 18 | *.userprefs 19 | *.csproj 20 | *.pidb 21 | *.suo 22 | *.sln 23 | *.user 24 | *.unityproj 25 | *.booproj 26 | 27 | # ============ # 28 | # OS generated # 29 | # ============ # 30 | .DS_Store 31 | .DS_Store? 32 | ._* 33 | .Spotlight-V100 34 | .Trashes 35 | Icon? 36 | ehthumbs.db 37 | Thumbs.db -------------------------------------------------------------------------------- /Documentation/language.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FarrokhGames/Language/1fbceeb2edeace21b169db51f6c668207932bca0/Documentation/language.gif -------------------------------------------------------------------------------- /Documentation/unittests.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FarrokhGames/Language/1fbceeb2edeace21b169db51f6c668207932bca0/Documentation/unittests.png -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Farrokh Games 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## An easy-to-use localization solution for Unity3D 2 | 3 | Zenject 4 | 5 | Please note that google translate was involved! :) 6 | 7 | --- 8 | 9 | ## Features 10 | 11 | - Super simple, driven by ```txt-files``` located in the Resource-folder. 12 | - Supports ```multiple languages with fallback``` for languages missing some of the localized texts. 13 | - Add ```placeholders``` inside your localized text, and fill them from code. 14 | - Defaults to the users ```system language```. 15 | - Contains behaviour for ```automatic localizing``` of your Unity UI Text-fields. 16 | 17 | --- 18 | 19 | ## Installation 20 | Simply copy the folder "Unity Project/Assets/Plugins" into your project and you're good to go. Optionally, you can add the folder "Unity Project/Assets/Example" to get started right away. 21 | 22 | --- 23 | 24 | ## Language Files 25 | Language-files are simple txt-files containing comments, identifiers, texts and placeholders. The naming convention needs to follow the ```SystemLanguage``` enum found in ```UnityEngine```. 26 | 27 | English.txt 28 | ``` 29 | # This is a comment 30 | my.identifier=A simple text 31 | gold.earned=You have earned {0} gold coins. 32 | ``` 33 | 34 | --- 35 | 36 | ## Usage 37 | The language system is accssible through the static ```Language.cs```. 38 | 39 | ```cs 40 | var myText = Language.Get("my.identifier"); // Returns "A simple text" 41 | var myParamText = Language.Get("gold.earned", 1000); // Returns "You have earned 1000 gold coins." 42 | ``` 43 | 44 | --- 45 | 46 | ## Changing Language 47 | Its possible to change language at runtime, provided the lanugage you're changing to actually exists and is represented by a txt-file. 48 | 49 | ```cs 50 | Language.CurrentLangauge = SystemLanguage.Swedish; // Changes current language to swedish 51 | ``` 52 | 53 | --- 54 | 55 | ## Callbacks 56 | Whenever the currrent language changes, the Language.OnLanguageChanged is invoked. This is useful as it lets you update your texts the instant the language changes. 57 | 58 | ```cs 59 | Language.OnLanguageChanged += () => { 60 | _goldText.text = Language.Get("gold.earned", _goldEarned); 61 | }; 62 | ``` 63 | 64 | --- 65 | 66 | # Unit Tests 67 | The Language system is tested with more than 60 Unit Tests that can be found in ```LanguageContainerTests.cs```, and ```LanguageManagerTests.cs```. 68 | 69 | Zenject 70 | 71 | --- 72 | 73 | ## License 74 | MIT License 75 | 76 | Copyright (c) 2017 Farrokh Games 77 | 78 | Permission is hereby granted, free of charge, to any person obtaining a copy 79 | of this software and associated documentation files (the "Software"), to deal 80 | in the Software without restriction, including without limitation the rights 81 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 82 | copies of the Software, and to permit persons to whom the Software is 83 | furnished to do so, subject to the following conditions: 84 | 85 | The above copyright notice and this permission notice shall be included in all 86 | copies or substantial portions of the Software. 87 | 88 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 89 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 90 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 91 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 92 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 93 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 94 | SOFTWARE. 95 | -------------------------------------------------------------------------------- /Unity Project/.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "files.exclude": 3 | { 4 | "**/.DS_Store":true, 5 | "**/.git":true, 6 | "**/.gitignore":true, 7 | "**/.gitmodules":true, 8 | "**/*.booproj":true, 9 | "**/*.pidb":true, 10 | "**/*.suo":true, 11 | "**/*.user":true, 12 | "**/*.userprefs":true, 13 | "**/*.unityproj":true, 14 | "**/*.dll":true, 15 | "**/*.exe":true, 16 | "**/*.pdf":true, 17 | "**/*.mid":true, 18 | "**/*.midi":true, 19 | "**/*.wav":true, 20 | "**/*.gif":true, 21 | "**/*.ico":true, 22 | "**/*.jpg":true, 23 | "**/*.jpeg":true, 24 | "**/*.png":true, 25 | "**/*.psd":true, 26 | "**/*.tga":true, 27 | "**/*.tif":true, 28 | "**/*.tiff":true, 29 | "**/*.3ds":true, 30 | "**/*.3DS":true, 31 | "**/*.fbx":true, 32 | "**/*.FBX":true, 33 | "**/*.lxo":true, 34 | "**/*.LXO":true, 35 | "**/*.ma":true, 36 | "**/*.MA":true, 37 | "**/*.obj":true, 38 | "**/*.OBJ":true, 39 | "**/*.asset":true, 40 | "**/*.cubemap":true, 41 | "**/*.flare":true, 42 | "**/*.mat":true, 43 | "**/*.meta":true, 44 | "**/*.prefab":true, 45 | "**/*.unity":true, 46 | "build/":true, 47 | "Build/":true, 48 | "Library/":true, 49 | "library/":true, 50 | "obj/":true, 51 | "Obj/":true, 52 | "ProjectSettings/":true, 53 | "temp/":true, 54 | "Temp/":true 55 | } 56 | } -------------------------------------------------------------------------------- /Unity Project/Assets/Examples.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 27b798a67493846598d729796850a1f1 3 | folderAsset: yes 4 | timeCreated: 1509799008 5 | licenseType: Free 6 | DefaultImporter: 7 | externalObjects: {} 8 | userData: 9 | assetBundleName: 10 | assetBundleVariant: 11 | -------------------------------------------------------------------------------- /Unity Project/Assets/Examples/Language.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: dc0085f6fae3f4d078c97dc276e309da 3 | folderAsset: yes 4 | timeCreated: 1509799027 5 | licenseType: Free 6 | DefaultImporter: 7 | externalObjects: {} 8 | userData: 9 | assetBundleName: 10 | assetBundleVariant: 11 | -------------------------------------------------------------------------------- /Unity Project/Assets/Examples/Language/LanguageButtons.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | using UnityEngine.UI; 5 | 6 | namespace FarrokhGames.Language 7 | { 8 | public class LanguageButtons : MonoBehaviour 9 | { 10 | [SerializeField] private Button _prefabButton; 11 | 12 | private Dictionary _buttons; 13 | 14 | void Awake() 15 | { 16 | _buttons = new Dictionary(); 17 | foreach (var language in Language.AllLanguages) 18 | { 19 | var btn = GameObject.Instantiate(_prefabButton.gameObject, Vector3.zero, Quaternion.identity, transform).GetComponent