BTW I will strongly recommend to go for separate files as translation tend to get bigger and once you will have 10+ languages that's 5-10mb of text... and for mobile games that's really matters... needless to say that loading smaller files (which you actually need) is much faster and consumes less memory. That's the reason I started to watch this tutorial, to replace bought ready solution which does not support splitting translation into multiple files. As for video - AWESOME tutorial!
@JuniorNetwork4 жыл бұрын
hi rick, how would we adjust the code for the separate translation files? ^^
@CrystalClod2 жыл бұрын
I am def way too late for this, for anyone in the future: 1) Change it into one "localised" dictionary in the "LocalisationSystem" script 2) In the translation file, only have the key and value pairs (remove the header and other languages) 3) change the value of "i" in the first "for" loop to 0, as you no longer have a header 4) remove attribute index, as you no longer need it 5) in the for loop, make "key"'s value "fields[0]" and "value"'s value "fields[1]" Now if you run the localisation system using the name of the file it should give you the correct one. When I clean up the code in my version a bit, I'll try adding a github link to it in another comment.
@AllDayBikes4 жыл бұрын
Maaaan, most of my game is based off this channels tutorials so far haha, thank you so much for your tutorials, one of the best
@ProtopopGames4 жыл бұрын
This is exactly what I was looking for - thank you. I used it to add localization to my next game update. The tutorial was concise, and it's great to be able to use external files. Csv seems really simple, universal and flexible. It would be nice to be able to download the .cs files because of the various fixes we have to make in the comments, but I get that it's also a good way to learn by trial and error without them too.
@antonymorsas5 жыл бұрын
This is one of the most valuable tutorials I´ve seen
@BalancingMonkeyGames5 жыл бұрын
I'm super looking forward to part 2!
@GameDevGuide5 жыл бұрын
Great to hear it! Check back on Monday ;)
@flameprincess73135 жыл бұрын
Perfect timing for me it seems! Thank you for this^^
@joeferreira33404 жыл бұрын
That's a classy solution for the problem. Thanks for the light!
@INeatFreak5 жыл бұрын
can you please share source codes of tutorial videos. it's really annoying to stop and copy the code every second.
@jakub96404 жыл бұрын
i recommend doing it like that and making sure you know whats going on, it helps a lot in the long run and helps you learn better :)
@RugbugRedfern4 жыл бұрын
@@jakub9640 He barely explains half of what he's doing. I'm not learning anything from this tutorial, I'm just mindlessly copying code. And I've used Unity for 2 years. What the hell does that Regex class do? He only explains tidbits of what he's doing, it would be much more helpful if I could just review the finished code.
@haachamachama74 жыл бұрын
@@RugbugRedfern I was even struggling trying to figure out what that private char ' " ' was, I thought it was 4 apostrophes XD
@jakubkohoutek52003 жыл бұрын
@@jakub9640 Yep, I am now reworking all the code to have separate files and compatibility with translation software, it really helps to actually understand what the code does.
@jakub96404 жыл бұрын
I found when I ran this that the text would appear as "Hello World!", instead of by itself without the quotation marks. To overcome this you can simply just trim the value before inputting it to the text box like so: value = value.TrimStart(' ', '"'); value = value.Replace("\"", ""); textField.text = value;
@utsavsinhzala5 жыл бұрын
Awsome bro. You Solved my problem of localization. You are amazing ❣️
@TrueIndian5 жыл бұрын
Damn such quality in tutorials...Thanks...keep making more.
@VHShark5 жыл бұрын
Keep on good work bro , you deserve a lot more subscribers ;)
@richarddoci5 жыл бұрын
Man, pretty amazing tutorial!
@Skycrafter3283 жыл бұрын
If you guys are looking for an easy free way of localization. Unity has its own localization asset since Unity version 2020. This is obviously if you don‘t want to do it urself and just trying to find a good free way without much work. I don‘t want to downtalk this channels videos at all, they are awesome and perfect if you want to do it all urself. In my opinions you should just sometimes use others ppls work to save time. Since this video was released before the Unity asset I just wanted to mention it for anyone interested!
@germannoobgaming4 жыл бұрын
I get an error with the StringSplitOptions saying it does not exist in the current context
@joshuamcmillan63904 жыл бұрын
Make sure you add "using System;" to the top of your file. By default, Unity does not add this, and is required to access StringSplitOptions (his editor must have a shortcut when he added the reference to automatically generate the using statement)
@germannoobgaming4 жыл бұрын
@@joshuamcmillan6390 tHANK YOU
@joshuamcmillan63904 жыл бұрын
@@germannoobgaming You're welcome! It seems like I've ran into everyone's issues in the comment section, and I've slowly been working through each of them until I got it done and sharing the results. The longest issue I had so far was the fact I accidentally added the file extension to the name, which Unity does not like lol
@ben_burnes4 жыл бұрын
@@joshuamcmillan6390 Thanks for this :)
@haachamachama74 жыл бұрын
@@joshuamcmillan6390 Thank you, Idk why GameDevStudios never mentions important things like adding Namespaces.... lol
@_firox_4 жыл бұрын
I don't understand why the regex is this long. A t first I thought it was to consider cases where there will be characters between the , and the first " but it's not. Even with the c# regex cheat sheet I don't achieve to understand this regex and why it's this long. Is anyone can explain why please ? For now it seems that an easier and working regexl is ",[^\"]*\"" Edit: I've finally understood why the regex used in the video is good and mine is not. The one is the video don't match the comma in the text you want to have. For the ones who would like to understand this regex here's a traduction: the , must be followed by the pattern "" repeated as much as one wants but can't be followed by the pattern ". The only problem of this regex is that it doesn't allow to use comma in a part of the text where text is between quotation marks. But that's more the fault of the used separators. I think just splitting line as the first one is enough.
@_g_r_m_3 жыл бұрын
If unity drops an error saying that SplitOptions.None doesn't exist in the current context just add using System at the top of the script.
@unuslupus-csa3 жыл бұрын
Probably a dumb question, but wouldn't it be just as easy to have a switch statement on the text assets in game?
@noeldev3 жыл бұрын
This was really helpfull, thanks a lot :D
@sistemover5 жыл бұрын
On my Unity 2018.4.11f1 its dont read csvFiles, its just take a empty string, i dont know whats to do !! (by google traslate from español) UPDATE: For whom he gave the same problem, I found the solution, and it was too simple, I don't know if he explained this at some point, my English is not the best, but I need to place in the TOP of the Using the following: > using System.IO; > using System.Linq; (by google traslate from español)
@JamalDolleyGames4 жыл бұрын
My text is displaying nothing, in which file should I add using System.IO; ???
@krzysztofparadowski6244 жыл бұрын
And how do I change the Language then Ingame?
@Pedro_Marangon4 жыл бұрын
I did that for testing purposes, you can create this method in the LocalisationSystem.cs: public static void SetLanguage(Language newLanguage) { language = newLanguage; } then, when you want to call this (for example, change to French), you only neeed to to LocalisationSystem.SetLanguage(LocalisationSystem.Language.French); and then uptade the text using the same logic from the Start() from the TextLocaliserUI.cs
@morkovkazet6664 жыл бұрын
@@Pedro_Marangon you best!
@moti1s4 жыл бұрын
I'll add to this, because i've been sitting until 7AM for this, so If you want to change localisation in game on a press of a button, then you need to: 1. Create a method in LocalisationSystem: public static Language SetLanguage(Language newLanguage) { language = newLanguage; return language; } 2. Create a script, with a method public void engLang(bool lang) { if(lang == true){ LocalisationSystem.SetLanguage(Language.English); Debug.Log(LocalisationSystem.SetLanguage(Language.English)); } } (same but French, instead of English on frLang method) 3. Add that script with a method to a button on click event 4. go back to TextLocaliserUI and change void start() to void update() so it would display it on change
@HomeGameCoder4 жыл бұрын
@@moti1s Hi. don't update text in the Update()! If you have lots of text elements, they will be updating every frame to the same text. Best solution is to subscribe the TextLocaliserUI to an evenSystem (check other tutorial in this channel) and everytime you change the language you also trigger the event once. You still can update on the fly but only rewrite everything once at change!
@Vueltero3 жыл бұрын
@@HomeGameCoder
@kotaromarunouchi52624 жыл бұрын
Cannot make new lines with the line separator( ) in your script. Is there anyone who already addressed this issue?
@arcday42814 жыл бұрын
use formatting tags like in the localisation file
@clevereengamingartstudio65274 жыл бұрын
Since Textmeshpro works like a html file, use Test this : "my name is Clevereen" It should display : my name is Clevereen
@mojzi1969 Жыл бұрын
if you are getting errors like no regex, no StringSplitOptions or no TextMeshPro just add using System; using System.Text.RegularExpressions; and using TMPro; to the top of your script. it solved for me
@Indie_Myke4 жыл бұрын
So I'm not very fluent into string separators that's the main reason for this question. The way I'm grabbing my .csv file is by exporting it from google sheets, the problem with google sheets is each element in the csv file doesn't have quotations just commas separating them out, which does not work with this solution. I've tried every which way to get this to work but my lack of knowledge in formatting is killing me right now. To state off no I can't just edit the file and add the quotations because every time I want to make a change to that language file I would have to go in and re-do everything that got overridden. Is there any way that I can use this solution but with the google sheets csv format?
@coreylister47074 жыл бұрын
Just have to read your CSVReader class - build your own CSVReader implementation to suit your file needs and you should be sweet the rest will be the same if you don't change your method names.
@coreylister47074 жыл бұрын
redo your CSVReader class*
@jochewi3 ай бұрын
I would appreciate an explanation of how to make the language change by pressing a button instead of rewriting the code, I'm having trouble doing this on my own because I don't understand the use of static
@mrYoshihiro5 жыл бұрын
Game Dev Guide : Hello, It is great video. But i have a few questions though: 1) Is there any way to use custom file with custom extension + encrypt data with some sort of BinaryFormatter ; 2) Is it possible to attach some function to a button which will pick language and update ALL interface elements with text localiser UI scripts without game reload ; 3) What is the best place to add isReady variable, which will check if all elements updated? For example we show loading screen till everything loading (for lots of localizations) P.S. Sorry! That is my best english. I am kind of new with c# and unity. And again thanks a lot for the video.
@JuniorNetwork4 жыл бұрын
I also need to know this: 2) Is it possible to attach some function to a button which will pick language and update ALL interface elements with text localiser UI scripts without game reload ; Does anyone know how to solve our need? If so, could you help us? *_*
@haachamachama74 жыл бұрын
Actually pretty amazing, it worked for the most part. But for some reason, for my second language everything ends in ". does anyone know why this might be?
@rikogames65864 жыл бұрын
When you're editing it add a comma at the end of each line and remove any spaces outside the quotes, so instead of this: "key_test", "Test this stuff","Teste isso" it would look like this: "key_test","Test this stuff","Teste isso", If you're using a spread sheet software, don't use Google sheets nor excel (thy don't save correctly) use Open Office and leave an empty row at the end only with the first cell filled to get a comma at the end of each line
@clevereengamingartstudio65274 жыл бұрын
Thanks a lot
@haachamachama74 жыл бұрын
@@rikogames6586 I actually forgot to respond to this haha, that fixed it, thank you!
@rodolforubens4 жыл бұрын
Ah very nice! Thanks a lot, plain and simple. The only thing I changed is that I only store the dictionary of the current system language. I made in a way that I find which is the player's system language (from Application.systemLanguage) and see if I have a corresponding dictionary for it, and then store only this one, when using the Localize method it makes the TryGetValue on the dictionary in use directly. Again, a million thanks!
@ryanmadden48664 жыл бұрын
Does anyone else get this error: ""TextMeshProUGUI' does not contain a definition for 'value' and no accessible extension method 'value' accepting a first argument of type 'TextMeshProUGUI' could be found (are you missing a using directive or an assembly reference?) for Unity 2019.3?
@toutEnVrac4 жыл бұрын
Yep
@hattoving3404 жыл бұрын
So when I run the script, the text doesn't show up ... Can anyone help me?
@RugbugRedfern4 жыл бұрын
Is there a way to have GetComponent() automatically run in the editor and bake in the value, so that when the scene starts not every piece of text is doing a GetComponent() call?
@hokahoka4204 жыл бұрын
I think a workaround is to make a custom class inheriting TMP_Text that has the functionality of the Localiser added. Then you replace your TMP_Text components with this new one. However, if you already have many of texts, this will be time consuming (but you leave out the GetComponent()). Also, you can Copy Component, Remove Component, Add New Component, Pase Component Values (should work on inherited class, IMO).
@micaiahstevens88405 жыл бұрын
Thanks to Hauka, for posting the code. Maybe ti did not like code in my comment. Anyyways if you add commas and spaces in the text file you can remove them with the file seperators, but then need to remove them from the headers, since it splits and add spaces. This makes the text file nicer to read IMO.
@Frenuellcrackser334 жыл бұрын
Incredibly awesome system to switch languages ! However special Characters like Ü,Ä,Ö etc dont display correctly. Ive seen other ppl having this problem but with no real solution :/ do you have to include a character set or something ? Its definitley not the font scince typing these character manuelly is no problem. I guess there getting messed up in the process of extracting them from the csv file. any thoughts ?
@Frenuellcrackser334 жыл бұрын
Just what i thought the csv file was not saved with propper encodeing... i wasnt set to UTF-8. btw you can build this system with json files, there is a unity tutorial. next time i am going to use that...
@_denzy_63104 жыл бұрын
Hook this up with google translate and you support any language possible. Epic stuff
@enolya4 жыл бұрын
Referencement, great job!
@onurarslanpay7213 жыл бұрын
While trying to translate some games (Ghost of a Tale) into my own language, there is a certain character limitation in Unity games. When more characters are entered, the game does not open. How can I overcome this situation? Thanks.
@btarg14 жыл бұрын
Wouldn't you want to use JSON instead?
@Videogueimeiro3 жыл бұрын
I don't know why but the text is always showing in english, even if I change the "language" variable to language.French
@Videogueimeiro3 жыл бұрын
Nevermind, I just messed up big xD
@SanyaBane5 жыл бұрын
3:15 so as i understand this screenshot is just here by some mistake? i mean, you tell us to leave no spaces between elements, but there are spaces on screenshot
@minosoft34715 жыл бұрын
Later in the code, around 4:15 he adds a TrimStart, removing the spaces.
@cmdrdyatlov4 жыл бұрын
Nice tutorial but cvs loader doesnt accept some characters like í á ě
@MeanMachine9955 жыл бұрын
Great tutorial! Does this work with WebGL by any chance? :)
@irusansonofarusan4 жыл бұрын
Good tutorial, thanks. One thing: using CSV isn't the best idea for localisation because CSV itself is standardised differently in different locales. Since much of Europe uses a comma as the decimal separator the standard there is to use a semi-colon as the separator instead. This can mean that CSV files are incorrectly loaded or incorrectly saved by their software. The simplest alternative is tab-separated, but it can be worth using a more expressive format depending on your strings.
@firattamur16823 жыл бұрын
Why do you think this is a problem? Because if we are creating csv file and csv loader then how can be problem with the format?
@irusansonofarusan3 жыл бұрын
@@firattamur1682 If it stays entirely within your toolchain, then - yes - that will be okay. But if one of your translators opens the file in Excel (which associates itself with .csv files by default), for example, then it can lead to problems. I've personally seen so many problems with .csv resulting from this that I entirely avoid the format where possible.
@firattamur16823 жыл бұрын
@@irusansonofarusan Yep I agree, thanks for reply.
@DanielByronYT5 жыл бұрын
I'm not using TextMesh Pro, and when I try and attach the script to a regular text object it throws me an error saying that a component can only have one graphic element. Any ideas on how to fix this?
@marcelinoborges50885 жыл бұрын
Try taking off the "[RequireComponent(typeof(TextMeshProUGUI))]" on the TextLocaliserUI script... Or just replace the TextMeshProUGUI for Unity's Text component.
@joshuamcmillan63904 жыл бұрын
If you are using Unity's default UI, you will need to reference it using "using Unity.UI;", change the RequireComponentAttribute to [RequireComponent(typeof(Text))], and then reference the Text component instead of the TextMeshProUGUI. The functions to write to the standard Text component should be very similar, so the code should be fine as is.
@DanielByronYT4 жыл бұрын
@@joshuamcmillan6390 Thanks for the detailed reply!
@majinnp5 жыл бұрын
I get an error when i run the game in preview mode, is there something wrong with the script? Otherwise the code compiles correctly. NullReferenceException: Object reference not set to an instance of an object CSVLoader.GetDictionaryValues (System.String attributeId) (at Assets/Scripts/CSVLoader.cs:23) LocalisationSystem.Init () (at Assets/Scripts/LocalisationSystem.cs:25) LocalisationSystem.GetLocalisedValue (System.String key) (at Assets/Scripts/LocalisationSystem.cs:33) TextLocaliserUI.Start () (at Assets/Scripts/TextLocaliserUI.cs:17)
@joshuamcmillan63904 жыл бұрын
Check to be sure your CSV file is in the proper "Resources" folder, as well as the csv file name and the string name for "csvLoader = Resources.Load();" in CSVLoader.cs are the same, *without the extension .csv*. This caused me to get the same NullReferenceException when it goes to pull the "CSVLoader.GetDictionaryValues();" Apparently, Unity doesn't like to have file extensions in the string names when dealing with resource files.
@RecOgMission2 жыл бұрын
Great, thanks! I had to use the following in Windows, else I had unwanted /r and " at the end of some lines: private static string[] lineSeparator = { System.Environment.NewLine };
@Guandonien5 жыл бұрын
I have 2 problems with the code: 1. The last word of the last key terminate on the by 'theword"' and when place a , in 'theword,' on the text file, this work pretty well. Why? 2. The 'ç' character don't work Sorry for my English!
@joshuamcmillan63904 жыл бұрын
You're good! While I'm not quite understanding your first question, the second one is a result of the font file probably not being compatible with that character. You'll have to find or make a font that contains that character. If that character does not exist in the font, or is not requested to be added to the Font Asset (assuming you are using TextMeshPro), then it will not be added to the asset in the font import window of TextMeshPro.
@OlivierLeclair4 жыл бұрын
@@joshuamcmillan6390 I have the same problem (ç and any special characters). I'll try to explain the issue the best I can: First of all, I am using the Arial font that supports French special characters as ç, à é, è and so on. I also suspected it at first, but the problem is not the font To make sure of that, I did the following test. I created a language selection menu with two buttons: "Français" and "Anglais". "Français" and "Anglais" are both the default string in the Text component before there is any localization. Yes, I am using Text component but the problem is the same with TextMeshProUGUI. In playmode, when I click on the "Anglais" button, the text of both buttons change to "French" and "English". But when I click on "French", they change to "Fran�ais " and "Anglais". So the issue is not the component or the font. I spent a few hours on Google and doing troubleshooting with no progress. If you or someone else could give me a hand, I would really appreciate it! UPDATE: Special characters are also broken in the console when I print the localized values
@joshuamcmillan63904 жыл бұрын
@@OlivierLeclair Hmm... What are you using to edit your CSV file? I've not had great luck with Excel understanding and saving CSV files with special characters. I use Visual Studio Code with a CSV extension to edit my file, and the special characters read fine.
@BloodKillerr Жыл бұрын
Hi. I've encountered quite a strange problem. I'm using this localization system for my android mobile game. When I'm running the game in editor or Unity Remote, everything works fine. But when I build and test it on my phone, all the strings, that have values from dictionary, have an additional quotation mark at the end. Does anyone know where the problem could be?
@gokhangumus44564 жыл бұрын
I think regex does not allow characters like ! or ? in the text. Does anyone have the same problem? Edit: I've deleted ? and ! in the regex and then it started to read ? and ! signs in the text. However, why were these signs were in regex at the beginning?
@mikhail_from_afar3 жыл бұрын
Slightly off topic, but does anyone know a good font with plenty symbols from other languages? I'm working on a game about words and want an ability to see and use esperanto, czech, polish, russian, belarusian words. Even Roboto does not have all that I need (I think it was lacking ў)
@youtissoum3 жыл бұрын
you made grammatical errors on the french of "is it working ?"
@X-mordred-X4 жыл бұрын
Awesome! Thanks!
@jakub96404 жыл бұрын
can someone explain to me how the field seperator works and why it looks like that? Thanks :)
@MultiLuminus3 жыл бұрын
I know I'm late and you probably don't need the answer anymore, but if anyone else is wondering, quotes (") are used to indicate where a string begins and ends. A \ infront of a quote just tells c# that the quote is not the end of the string, but part of it.
@aleksandrs.15314 жыл бұрын
Great tutorial. But I have an error in unity when running. I get: NullRefenceException ... not set to an instance of an object CSVLoader.GetDictionaryValues ( System,String attributeId) The line in the code is this string[] lines = scvFile.text.Split(lineSeparator); Any ideas what is wrong?
@KynsonMitchell4 жыл бұрын
I was having the same problem, and found this in another comment: "Check to be sure your CSV file is in the proper "Resources" folder, as well as the csv file name and the string name for "csvLoader = Resources.Load();" in CSVLoader.cs are the same, *without the extension .csv*."
@aleksandrs.15314 жыл бұрын
@@KynsonMitchell Thanks a lot! That was the issue! Now it works
@SteffoSpieler4 жыл бұрын
I have an error: Every Translation but the last one has a " at the end! help? (in my secound language btw.) In the first it works
@joshuamcmillan63904 жыл бұрын
Don't worry, you're not the first person with this problem! It's because TrimEnd() is not quite behaving as we were expecting. Check out Marcelino Borges comment below for his description of the problem and the solution he came up with. It helps solve the error!
@SteffoSpieler4 жыл бұрын
@@joshuamcmillan6390 thanks! :)
@joshuamcmillan63904 жыл бұрын
@@SteffoSpieler You're welcome! Good luck with the remainder of the tutorial
@hovestergamedev20464 жыл бұрын
Returning Null... I reviewed everything and there is o difference in the code.
@sayama20824 жыл бұрын
I don't know if it's this, but, be sure to place your file in a folder name "Resources" I found some answer there, maybe ur gonna find yours answers.unity.com/questions/1411034/textasset-return-null.html
@clevereengamingartstudio65274 жыл бұрын
For me it was the regex, took me time to understand. Regex CSVParser = new Regex(",(?=(?:[^\"]*\"[^\"]*\")*(?![^\"]*\"))");
@bredj08344 жыл бұрын
amazing
@Ephjoshy10 ай бұрын
does not seem to work :(
@nadaked3 жыл бұрын
thnx a lot
@menzo96413 жыл бұрын
сделай тутор по магазину
@kristianrhyuben4 жыл бұрын
I created some script like that but using xml here is link to the script github.com/kiriru96/UnityMultiLanguageChange
@KaffeinatedAura4 жыл бұрын
"So localisation is-": TF2 fandom: WE KNOW
@TanninZero4 жыл бұрын
This is a really bad idea. Actually, this isn't localization at all, it is just translation. Localization is about more than swapping one text with another. Other languages have different ways of representing dates, numbers, plural forms, different text structure, sorting alphabetically differs between languages and so on. Localization is an extremely complex topic, way too much so to roll your own for an indie game - so you shouldn't! Instead of writing your own localization system that is never going to be more than a hack and can maybe deal with a handful of european languages, better spend that time integrating a proper i18n library written by people who actually did some research. Following this tutorial you waste your time *and* insult your users.
@hazoveu2 жыл бұрын
unity error NullReferenceException: Object reference not set to an instance of an object CSVLoader.GetDictionaryValues (System.String attributeId) (at Assets/CSVLoader.cs:23) LocalisationSystem.Init () (at Assets/LocalisationSystem.cs:25) LocalisationSystem.GetLocalisedValue (System.String key) (at Assets/LocalisationSystem.cs:33) TextLocaliserUI.Start () (at Assets/TextLocaliserUI.cs:16) how to fix it?
@betadv3 жыл бұрын
keeps saying "NullReferenceException: Object reference not set to an instance of an object" if I use it in an Update function, and the value being returned is Null, any idea why? I want to make it so that it updates live whenever you change the language.