agens-no / polyglotunity Goto Github PK
View Code? Open in Web Editor NEWA Polyglot Localization plugin for Unity3d that translates games to many languages
Home Page: http://bit.ly/1ESPiO6
License: MIT License
A Polyglot Localization plugin for Unity3d that translates games to many languages
Home Page: http://bit.ly/1ESPiO6
License: MIT License
Hi!
I've been using polyglot for a while, and I LOVE this tool, it's crazy useful. Now, I want to add a new language that it's not included in the default languages (Galician, from Spain), but I don't know how. I have added it to the enum "Languages" but it does weird things.
Is there an easy way?
Thanks!
Carlos
Hello, I am really enjoying this plugin for localisation! Thank you very much for it!
However, I struggled to get it up and running with a custom localisation file. It would be great to have better documentation about it, as I had to debug the code to understand how the formats and requirements for the localisation file are.
As I wish for new developers to have an easier time when integrating this tool, I would suggest to:
Hey there, great tool & great spreadsheet. I have a quick query about the README.
I've copied & duplicated the sheet, but the following line is confusing me:
Duplicate the polyglot master sheet and remove all the keys from line 7. The importer parses everything line after the term "polyglot", "PolyMaster" or "BEGIN".
Do you mean 'line 6'? Or do I need to leave in 'polyglot' so it begins parsing after that?
(I'm sure I'll have an answer after actually testing it - however, just posting this here so I can refer back to it & request to update the README if necessary)
I want to create localisation in code without using any external files or anything, is it possible and if so: how can I do it?
When using line breaks in the spreadsheet they can be exported with csv. Sadly the parser is not capable of handling that. We would either need to rewrite the parser or use an established parser to get the job done properly. As for the external parser, I found https://github.com/joshclose/csvhelper
If we want to rewrite the existing parser, we would need to check for each '\n' and ',' if it is in between quotes. Not quite sure if there is an elegant version of doing that, but I think it might become a bit tricky to do it completely properly without creating too much overhead.
Any thoughts which road we should head down?
The integration produces the following compile error in Unity 5.6:
Assets/Polyglot/Scripts/GoogleDownload.cs(25,23): error CS0103: The name `UnityWebRequest' does not exist in the current context
Changing line 4 from UNITY_2017_2_OR_NEWER to UNITY_5_5_OR_NEWER seems to fix it.
I have translated the Polyglot master sheet to Arabic, but there is a severe issue that needs to be addressed in order to use this language in Unity.
Arabic is a cursive language where the letters in every word are connected to each other using alternative font characters. Unity, however, doesn't recognize that use-case and the Arabic words are split up and illegible. This can be fixed using a free store asset called "Arabic Support" also licensed under MIT like "PolyglotUnity".
It is found here:
https://www.assetstore.unity3d.com/en/#!/content/2674
https://github.com/Konash/arabic-support-unity
In order to fix the Arabic language for "PolyglotUnity", here are my suggested changes to this repo:
A) Put the file "Arabic Support > ArabicSupport.dll" into this repo.
B) In "PolyglotUnity > LocalizedText.cs > SetText()", add an if condition for Arabic:
protected override void SetText(Text text, string value) {
if (text == null) {
Debug.LogWarning("Missing text component for " + this, this);
return;
}
if (Localization.Instance.SelectedLanguage == Language.Arabic) {
text.text = ArabicFixer.Fix(value, true, true);
} else {
text.text = value;
}
}
Here is the result (Before & after):
Of course, I believe this should be done with the approval of the author of "Arabic Support" @Konash and the maintainers of this repo.
The download from Google sheet functionality doesn't work for me in Unity 5.6, either with the master sheet or the custom sheet. The progress never goes beyond 0. It does work in Unity 2018.3.
Canceling the progress bar for some reason doesn't work so I had to force quit Unity for every attempt. To address this I added some timeout code.
float lastProgress = 0;
System.DateTime lastProgressTime = System.DateTime.Now;
while (!www.isDone)
{
#if UNITY_5_5_OR_NEWER
var progress = www.downloadProgress;
#else
var progress = www.progress;
#endif
if (progressbar != null && progressbar(progress))
{
done(null);
yield break;
}
if (progress > lastProgress)
{
lastProgress = progress;
lastProgressTime = System.DateTime.Now;
}
if ((System.DateTime.Now - lastProgressTime).TotalSeconds > 10)
{
Debug.LogError("Google sheet timed out.\nURL:" + url);
done(null);
yield break;
}
yield return null;
}
Furthermore, to make the progress bar go away when an error happens, I had to add a EditorUtility.ClearProgressBar(); call in the DownloadComplete method in LocalizationEditor.cs.
However, these progress bar workarounds don't address the core issue that the localization data can't be downloaded in the first place.
Polyglot was very recently updated where a new Master sheet was added.
https://docs.google.com/spreadsheets/d/17f0dQawb-s_Fd7DHgmVvJoEGDMH_yoSd8EYigrb0zmM/edit#gid=423963190
In my opinion, this will require changes in this repo:
A) In "LocalizationEditor.cs", the new default gid number should be changed from "296134756" to "423963190". The old number will download "Master_Old" and the new number will download "Master".
B) A few changes in "Langage.cs" are required in my opinion: "Language.cs" is not showing all the new languages in the correct order. This causes issues in "LocalizationImporter.cs". See 1-to-3 below:
Selecting the second-to-last language, "Arabic," gives an error because it is listed as number 28. Arabic should be ordered to be number 26, coming right after Hebrew. After doing this minor change, Arabic will become selectable in my tests.
Malay and Indonesian have been removed or renamed from the master sheet (?)
The last language in the new Master sheet, "Bosnian," is missing and unselectable in the "supported languages." I don't know how to fix this because I don't know what the correct equivalent for "SystemLanguage.Bosnian".
C) (extra) Update the repo to Unity 2017.2
PS. Correct me if I'm wrong about any of the above information. I've only looked at this project today, and I don't know the contribution policy for this plug-in.
Hi, I have some suggestions for some tasks that could be automated to improve usability.
hello
can you support json fotmat type
I have some (English) text in a Text
Component that has a LocalizedText
. However, when the text gets translated, it automatically gets aligned to the left because of protected override void UpdateAlignment(Text text, LanguageDirection direction)
...
I would like to see an option on LocalizedText
to maintain the original text alignment. Do you accept pull requests?
In the LocalizedTextComponent
, the methods to add parameters AddParameter(..)
triggers an error - FormatException - if the given string to format requires more than 1 parameter.
This is because every time a parameter is added via these methods, it will call OnLocalize()
and thus try to format the string with the first added parameter. And currently the API does not contain a method to add a set of parameters at once.
As an example:
Hello, my name is {0} and I work as {1}
As a workaround I added a method SetParameters(params object[] parameters)
in the LocalizedTextComponent
:
public void SetParameters(params object[] parameters) {
ClearParameters();
this.parameters.AddRange(parameters);
OnLocalize();
}
Could this method be an alternative to the AddParameter()
methods?
The method CanCacheInspectorGUI needs to be wrapped in #if UNITY_2017_3_OR_NEWER
Hi,
if is possible use this plugin from script can you write some docs?
Hello,
When changing the selected language via code, I am using (e.g.) Localization.SelectedLanguage = Language.Dutch
. This has a caveat as is it will change the serialized field selectedLanguage
in the Localization ScriptableObject. This can cause some difficulties in the Unity Editor when working in a team and everyone starts seeing changes to this file.
Is this the correct way to change the selected language in run-time? If so, could a separate approach be considered for the selected language? (ie, do not set the serialized field but another cached field instead?)
I just had the problem that my localization filw was not parsed anymore, even though I just added three simple strings to the file. After quite a while I found the problem: One added ID was "ENDSCREEN_BUTTON", which triggered if(key.StartsWith("END"))
in LocalizationImporter.cs.
I think another convention than checking if the string starts with END would be benefitial for the project. I suggest to check for an equals instead of using StartsWith()
. To stay consistent I propose to do this change for the start as well. So the code would change to
if (!canBegin)
{
if (key == "Polyglot" || key == "PolyMaster" || key == "BEGIN")
{
canBegin = true;
}
continue;
}
if (key == "END")
{
break;
}
If this is in the interest of those involved I would create a PR for it :)
Hello
First of all your asset seems to work pretty well.
I just found a bug with the TextMeshPro integration.
When I try to use Polyglot with TextMeshPro from the Unity Package Manager (upm) I got the following error e many different scripts:
Assets/Polyglot/Scripts/LocalizedTextMeshPro.cs(3,7): error CS0246: The type or namespace name `TMPro' could not be found. Are you missing an assembly reference?
My friend (@Lawendt) discovered this link that suggested the solution.
Open PolyglotScripts.asmdef
and PolyglotEditor.asmdef
in a text editor and manually add the dependency to Unity.TextMeshPro
.
Your files should look like this:
PolyglotScripts.asmdef
{
"name": "Polyglot.Scripts",
"references": ["Unity.TextMeshPro"],
"optionalUnityReferences": [],
"includePlatforms": [],
"excludePlatforms": [],
"allowUnsafeCode": false
}
PolyglotEditor.asmdef
{
"name": "Polyglot.Editor",
"references": [
"Polyglot.Scripts",
"Unity.TextMeshPro"
],
"includePlatforms": [
"Editor"
],
"excludePlatforms": []
}
This makes the scripts find the dependency of TextMeshPro and everything seems to be working fine.
Someone in the forum said that the assembly definition file will provide a way to add dependencies to unity packages (from upm) through the editor, for now, the solution is to manually add it.
Unity 2018.1.3f1
TextMeshPro 1.2.3 (from upm)
Hi,
I imported the Asset Folder contents into my 2017.1.1f1 project and am getting the following Error now:
Assets/Polyglot/Editor/LocalizationEditor.cs(226,17): error CS1061: Type
UnityEngine.Networking.UnityWebRequest' does not contain a definition for SendWebRequest' and no extension method
SendWebRequest' of type UnityEngine.Networking.UnityWebRequest' could be found. Are you missing an assembly reference?
Indeed, the Class UnityWebRequest does not contain mentioned Method
Also, could you clarify the install instrucions a bit? There are the project files as well as 2 unity packages. What is the correct install procedure?
Thank you, this tool looks really awesome!
Awesome project you guys have made, but it seems like nobody maintain this project any more, issues and pr exists for long time, I used PolyglotUnity in my game and I really like it, I have fixed some bugs and added some features for it, so if you guys still maintain this repo, I'd like to pull some requests, or I want to fork this repo to maintain this great plugin by myself and continue making it better, hope for your reply.
I want to craft an auto update funtion. compare CSV MD5 .then download new CSV file and import into game。
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.