AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   print in another lang (https://forums.alliedmods.net/showthread.php?t=332492)

newone123 05-15-2021 19:04

print in another lang
 
i have string with non-eng words.
when i print its reversing the words, how i can display correctly ?

if its help i read from json with: json_object_get_string() func (the words that i want)
and print with: client_print(0, print_chat, "[%s")

fysiks 05-15-2021 23:56

Re: print in another lang
 
Quote:

Originally Posted by newone123 (Post 2746909)
when i print its reversing the words

What does that mean? Please show an example of the input (presumable your file) and the output (what you see in chat).

newone123 05-16-2021 10:43

Re: print in another lang
 
Quote:

Originally Posted by fysiks (Post 2746922)
What does that mean? Please show an example of the input (presumable your file) and the output (what you see in chat).

https://pasteboard.co/K2aDscB.png

fysiks 05-16-2021 15:42

Re: print in another lang
 
Attach the plugin and JSON file so that we can see and test the code.

kww 05-17-2021 12:47

Re: print in another lang
 
maybe it happens because of Hebrew symbols?

newone123 05-17-2021 14:22

Re: print in another lang
 
Quote:

Originally Posted by fysiks (Post 2747006)
Attach the plugin and JSON file so that we can see and test the code.

I think its really unrelated because eng it reads excellent hebrew not.
after i get json file and read it
Code:

public read() {
        new JSON:decodingJson = json_parse("/addons/java/alerts.json", true)
        if(json_is_array(decodingJson)) {
                new JSON:firstObj = json_array_get_value(decodingJson, 0)
                if(firstObj) {
                        new cityKey[] = "data", dateKey[] = "alertDate"
                        new vcity[101], vdate[101]
                        new ok = 0
                        if(json_object_get_string(firstObj, cityKey, vcity, charsmax(vcity))) ok++
                        else client_print(0, print_chat, "[AMX] cant get the city by key = %s", vcity)
                        if(json_object_get_string(firstObj, dateKey, vdate, charsmax(vdate))) ok++
                        else client_print(0, print_chat, "[AMX] cant get the date by key = %s", vdate)
                        if(ok == 2) {
                                new ocity [101], odate[101]
                                get_pcvar_string(cvar_City, ocity, charsmax(ocity))
                                get_pcvar_string(cvar_Date, odate, charsmax(odate))
                                if(!equal(ocity, vcity) || !equal(odate, vdate)) {
                                        client_print(0, print_chat, "[AMX] alert %s under attack!", vcity)
                                        set_pcvar_string(cvar_City, vcity)
                                        set_pcvar_string(cvar_Date, vdate)
                                        client_cmd(0, "spk %s", "/addons/java/alert.wav")
                                } else client_print(0, print_chat, "[AMX] the last attack was in  %s ", vcity)
                        }
                        json_free(firstObj)
                } else client_print(0, print_chat, "[AMX] cant load first object")
                json_free(decodingJson)
        } else client_print(0, print_chat, "[AMX] json file not readable")
}

the json file that i received from curl (just few lines):
Code:

[{"alertDate":"2021-05-16 18:49:19","title":"התרעות פיקוד העורף","data":"אורים"},{"alertDate":"2021-05-16 18:49:17","title":"התרעות פיקוד העורף","data":"מגן"},{"alertDate":"2021-05-16 18:49:17","title":"התרעות פיקוד העורף","data":"ניר עוז"},{"alertDate":"2021-05-16 18:49:17","title":"התרעות פיקוד העורף","data":"עין הבשור"},{"alertDate":"2021-05-16 18:42:40","title":"התרעות פיקוד העורף","data":"ארז"},{"alertDate":"2021-05-16 18:27:55","title":"התרעות פיקוד העורף","data":"כיסופים"},{"alertDate":"2021-05-16 18:18:00","title":"התרעות פיקוד העורף","data":"אזור תעשייה עד הלום"},{"alertDate":"2021-05-16 18:18:00","title":"התרעות פיקוד העורף","data":"אמונים"},{"alertDate":"2021-05-16 18:18:00","title":"התרעות פיקוד העורף","data":"בית עזרא"},{"alertDate":"2021-05-16 18:18:00","title":"התרעות פיקוד העורף","data":"גבעתי"},{"alertDate":"2021-05-16 18:18:00","title":"התרעות פיקוד העורף","data":"ניצן"},{"alertDate":"2021-05-16 18:18:00","title":"התרעות פיקוד העורף","data":"עזר"},{"alertDate":"2021-05-16 18:18:00","title":"התרעות פיקוד העורף","data":"עזריקם"},{"alertDate":"2021-05-16 18:18:00","title":"התרעות פיקוד העורף","data":"שדה עוזיהו"},{"alertDate":"2021-05-16 18:17:25","title":"התרעות פיקוד העורף","data":"אשדוד - א,ב,ד,ה"},{"alertDate":"2021-05-16 18:17:25","title":"התרעות פיקוד העורף","data":"אשדוד - ג,ו,ז"},{"alertDate":"2021-05-16 18:17:25","title":"התרעות פיקוד העורף","data":"אשדוד - ח,ט,י,יג,יד,טז"},{"alertDate":"2021-05-16 18:17:25","title":"התרעות פיקוד העורף","data":"שתולים"},{"alertDate":"2021-05-16 18:17:24","title":"התרעות פיקוד העורף","data":"אשדוד - יא,יב,טו,יז,מרינה"},{"alertDate":"2021-05-16 18:17:18","title":"התרעות פיקוד העורף","data":"בת הדר"},{"alertDate":"2021-05-16 18:17:18","title":"התרעות פיקוד

newone123 05-17-2021 14:23

Re: print in another lang
 
Quote:

Originally Posted by kww (Post 2747084)
maybe it happens because of Hebrew symbols?

im know its because non eng lan, and how did you know its heb lol ?

kww 05-17-2021 14:55

Re: print in another lang
 
Quote:

Originally Posted by newone123 (Post 2747092)
im know its because non eng lan

not really. You can use any language that is not written from right to left and it will have the usual spelling, otherwise it will be distorted like in your screenshot

Quote:

Originally Posted by newone123 (Post 2747092)
how did you know its heb lol ?

just saw familiar characters:)

fysiks 05-17-2021 23:43

Re: print in another lang
 
Unfortunately, I'm unable to test this (and I'm not familiar with how computers handle RTL languages) because apparently my game doesn't use a font that supports Hebrew so I don't see anything in-game. My first guess would be that maybe the game can't handle RTL and LTR languages being mixed in a single line (I'm not even entirely sure it handles RTL at all but I assume it does). What happens if the only text being printed is RTL (Hebrew), with and without the data provided by the JSON (I doubt it has anything to do with the JSON file itself).

newone123 05-18-2021 00:27

Re: print in another lang
 
Quote:

Originally Posted by fysiks (Post 2747145)
Unfortunately, I'm unable to test this (and I'm not familiar with how computers handle RTL languages) because apparently my game doesn't use a font that supports Hebrew so I don't see anything in-game. My first guess would be that maybe the game can't handle RTL and LTR languages being mixed in a single line (I'm not even entirely sure it handles RTL at all but I assume it does). What happens if the only text being printed is RTL (Hebrew), with and without the data provided by the JSON (I doubt it has anything to do with the JSON file itself).

I thought so (not related to json)
heb its write from right to left
eng write from left to right
i think this is the problem
there any way use reverse loop on the string even char by char and make it right ?


All times are GMT -4. The time now is 02:39.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.