SpacehuhnTech / esp8266_deauther

Affordable WiFi hacking platform for testing and learning
http://deauther.com
Other
13.33k stars 2.57k forks source link

[RTL] Hebrew #909

Open itsik-b opened 6 years ago

itsik-b commented 6 years ago

I've translated lang file for HEBREW language. I've managed to create the he.lang.gz file and created the webfile.h with the webConverter.py utility. but it doesn't seem to work. I've set the WEBSPIFFS option in SETTINGS and confirmed that the file he.lang.gz copied to SPIFFS.

What am I missing ? he.lang.gz he.lang.txt

tobozo commented 6 years ago

Some of the slashed quotes are mistyped (found one with a space between / and "), this makes the JSON parsing fail and the webUI loads the default language.

image

You can use this tool to pre-validate your JSON. Or lazy fix: replace all slashed \" quotes by directional signs such as « and »

itsik-b commented 6 years ago

I removed all escape signs... still not good. I've tried to change to RU lang, didn't change either, may be the problem is the lack of support on utf-8 files ?

tobozo commented 6 years ago

Please submit your changes so we can cross-verify (i.e use gist or json validator online or pastebin).

I doubt there's a problem with utf8 otherwise we'd already know.

If the file is valid JSON and correctly zipped then it's a full browser problem, but I guess you already have Hebrew installed on the phone you're using to test this, right ?

One way to test the ESP is doing its part is to directly access the he.lang(.gz) file from your mobile browser.

Another lazy test: overwrite a language file you know is working (e.g. German) with the hebrew file, then load this language from the webUI, and tell us what you get.

itsik-b commented 6 years ago

Attached the clean lang file, I can't find errors in it.

Hebrew lang installed on my browsers :) (desktop and mobile phone)

I've tested it from the ESP (http://deauth.me/web/lang/he.lang.gz) the JSON file was loaded O.K. : screenshot_2018-07-04-09-58-51

he_clean.lang.txt he.lang.gz

itsik-b commented 6 years ago

got it to work. wifi.h needed to be fixed: wifih-fix

Now I'll be able to format it better... I'll upload the fixed lang file when I'm done.

itsik-b commented 6 years ago

Is there a way to make the text right alignment ?

screenshot_2018-07-04-10-33-46

tobozo commented 6 years ago

there are different approaches to that

1) RTL page html { direction: rtl; } 2) RTL layout section { direction: rtl; } 3) RTL blocks span { direction :rtl; }

Note that depending on the layout you sometimes have to use both directions in the same document:

 html { direction: ltr; } 
 span { direction: rtl; }

Full RTL page will probably trigger the directional anomalies you usually find on LTR-only layouts, where parts are explicitely using text-align:left.

If you come to modify the css, make sure you prefix all your extra directives like this:

[lang="he"] div.blah > span.meh { 
  direction: rtl; 
  text-align:left 
}
itsik-b commented 6 years ago

I don't want to mess the other LTR languages. I can add before every RTL text ‮ (Unicode Bidirectional) which will work as RTL text. But I need to change the alignment of the paragraphs. any ideas how to do it without affecting the other LTR langs ?

tobozo commented 6 years ago

the bidi byte won't fix the left/right alignment problems, and it's implicitly inserted anyway

if things are made correctly on the layout when you switch languages, all you need is CSS, you can use it in a way it won't interfer with LTR languages.

e.g. html[lang="he"] your.directive.here

in order to get the right lang attribute to the <html> tag, you need to modify a function in site.js as follows:

function parseLang(fileStr){
    langJson = JSON.parse(fileStr);
    if(langJson["lang"] != "en"){// no need to update the HTML  
        var elements = document.querySelectorAll("[data-translate]");
        for (i = 0; i < elements.length; i++) {
            var element = elements[i];
            element.innerHTML = lang(element.getAttribute("data-translate"));
        }
    }
        document.querySelector('html').setAttribute("lang", langJson["lang"] );
    if(typeof load !== 'undefined') load();
}