1. Hey! Guest! The 36th GMC Jam will take place between February 27th, 12:00 UTC - March 2nd, 12:00 UTC. Why not join in! Click here to find out more!
    Dismiss Notice
  2. NOTICE: We will be applying a Xenforo update on Tuesday 25th of February. This means that from approximately 10:00 to 14:00 BST the forums will be offline (or possibly longer). Sorry for the inconvenience! Official Announcement here.

GMS 2 [Solved] Issues with drawing Cyrillic text from a .ini file

Discussion in 'Programming' started by m4meteor, Jun 11, 2019.

  1. m4meteor

    m4meteor Member

    Joined:
    Apr 19, 2019
    Posts:
    6
    In my game I have setup a localization system using an included .ini file. The strings.ini file looks like this
    Code:
    [english]
    101=Resume
    102=Settings
    103=Quit
    104=Video
    105=Audio
    106=Controls
    107=Back
    108=Resolution
    109=Fullscreen mode
    110=Master
    111=SFX
    112=Music
    113=Walk left
    114=Walk right
    115=Jump
    116=Climb/Up
    117=Descend/Down
    118=General
    119=Language
    120=English
    121=Russian
    122=On
    123=Off
    
    [russian]
    101=Продолжить
    102=Настройки
    103=Выйти
    104=Видео
    105=Аудио
    106=Управление
    107=Назад
    108=Расшерение экрана
    109=Полноэкранный режим
    110=Мастер
    111=Эффекты
    112=Музыка
    113=Идти налево
    114=Идти направо
    115=Прыгать
    116=Подниматься/Вверх
    117=Спускаться/Вниз
    118=Основные
    119=Язык
    120=Англиский
    121=Русский
    122=Вкл
    123=Выкл
    Now in my game i have set-up a script, that looks like this
    Code:
    ///@desc string_lang(ini_index)
    ///@arg ini_index
    
    var search = argument0;
    
    switch (global.language)
    {
        case lang.english: var language = "english"; break;
        case lang.russian: var language = "russian"; break;
    }
    
    ini_open("strings.ini");
    var find_string = ini_read_string(language, string(search), "Error");
    ini_close();
    
    return find_string;
    
    So, now when I want to have a string translated to russian and english, for example, instead of putting
    Code:
    var text = "Resume"
    , I would put
    Code:
    var text = string_lang(101)
    Which would still be equal to "Resume" if global.language = lang.english but if global.language = lang.russian it would be equal to "Продолжить" which is the translation I want. Until here it is all ok, but when I get to print the string in Russian it prints boxes.

    Please note: I have a font that supports all Cyrillic letters and I have added a range for all the cyrrilic letters, yet still this problem happens. I also know that the problem isn't in the font because when I simply print a russian string without using the string_lang script it prints it perfectly.

    From my debug testing I know that the problem is when the string_lang reads the Russian strings from the .ini file. I know that because i've setup a variable be equal to string_lang(101) when language is Russian and from the debugger I can see that the variable is equal to "����������" instead of "Продолжить".

    Briefly:

    The problem is when I read a cyrillic string from a .ini file, Gamemaker returns it as strange boxes ("��������")

    How do I fix this?
     
    Last edited: Jun 11, 2019
  2. m4meteor

    m4meteor Member

    Joined:
    Apr 19, 2019
    Posts:
    6
    Oh i forgot to encode the .ini file to UTF-8 whhops my bad
     
  3. jifeng

    jifeng Member

    Joined:
    Dec 10, 2019
    Posts:
    2
    Hello, I see that the code you wrote seems to be complete. I'm a novice who just learned gms2. I learned localization all night and didn't find a proper tutorial. Can you teach me? I want to know the process and basic operation of localization. Thank you.
     
  4. rIKmAN

    rIKmAN Member

    Joined:
    Sep 6, 2016
    Posts:
    5,043
    There are quite a few guides and tutorials on localisation on here, reddit and Youtube etc

    If you do a Google search for "gamemaker localization" you will find many of them, but here is one on this very forum that uses Json to localise game text:
    https://forum.yoyogames.com/index.php?threads/how-to-localize-your-game-using-json.55568/
     
  5. jifeng

    jifeng Member

    Joined:
    Dec 10, 2019
    Posts:
    2

Share This Page