Project-OSRM / osrm-text-instructions

Text instructions from OSRM route responses
BSD 2-Clause "Simplified" License
89 stars 62 forks source link

Add Hungarian localization #274

Closed yuryleb closed 5 years ago

yuryleb commented 5 years ago

Issue

Initial Hungarian translation contributed by @kiskunk initally discussed in #271. Thanks a lot!

Tasklist

yuryleb commented 5 years ago

No problem, that's the review goal is 😉

alexwyattdev commented 5 years ago

No problem, that's the review goal is 😉

Ok, will I get a new notification if the new review is available, or I have to check back regularly? Thanks.

yuryleb commented 5 years ago

I'll add comment here and then you'll get a notification. Did you already update translation on Transifex?

alexwyattdev commented 5 years ago

I'll add comment here and then you'll get a notification. Did you already update translation on Transifex?

Yes, I did it before commenting on the review here.

yuryleb commented 5 years ago

IMHO missing whitespace after {modifier} in new name stuff:

        "merge": {
            "default": {
                "default": "Soroljon be {modifier}",
                "name": "Soroljon be {modifier}a(z) {way_name} felé",
                "destination": "Soroljon be {modifier} ehhez: {destination}"
            },
alexwyattdev commented 5 years ago

IMHO missing whitespace after {modifier} in new name stuff:

        "merge": {
            "default": {
                "default": "Soroljon be {modifier}",
                "name": "Soroljon be {modifier}a(z) {way_name} felé",
                "destination": "Soroljon be {modifier} ehhez: {destination}"
            },

Fixed it, tho it's really hard to keep track since almost every value exist 6 times.

yuryleb commented 5 years ago

Actually no, only destination was changed but name still need for whitespace:

        "merge": {
            "default": {
                "default": "Soroljon be {modifier}",
                "name": "Soroljon be {modifier}a(z) {way_name} felé",
                "destination": "Soroljon be {modifier} a(z) {destination} irĂĄnyĂĄba"
            },

And there are several similar cases, I recommend to use Transifex search for translated strings with }a pattern.

alexwyattdev commented 5 years ago

I only saw one, fixed, then searched for }a and found nothing. Is it possible to remove the ultimate redundancy somehow so every string would be there only 1 times?

yuryleb commented 5 years ago

I pushed your updated translation, please review result again.

IMHO there are extra whitespaces in name and ref now :wink:

        "phrase": {
            "two linked by distance": "{instruction_one} , majd {distance} mĂșlva, {instruction_two}",
            "two linked": "{instruction_one} , majd {instruction_two}",
            "one in distance": "{distance} mĂșlva {instruction_one}",
            "name and ref": "{name} ( {ref} )",
            "exit with number": "{exit} kijĂĄrat"
        },
alexwyattdev commented 5 years ago

Sorry, i wanted to make sure there is always whitespace, tomorrow I will check them, so to be clear there can be braces and commas after them ?

yuryleb commented 5 years ago

I suppose there should be just "name and ref": "{name} ({ref})",

yuryleb commented 5 years ago

Next commit pushed. But now there are extra whitespaces 😞

alexwyattdev commented 5 years ago

Transifex really plays out its cards... oh well, tried to fix them all.

yuryleb commented 5 years ago

Committed last fix. Translation looks good for me now 👍

BTW maybe you could also add translation to the frontend? It's necessary just add new hu.js into i18n folder with similar content:

module.exports = {
  name: 'English',
  key: 'en',
  'Open in Debug Map': 'Open in Debug Map',
  'Open in Mapillary': 'Open in Mapillary',
  'GPX': 'Export GPX file',
  'Open in editor': 'Open in editor',
  'Open in JOSM': 'Open in JOSM',
  'Select language': 'Select language',
  'Start - press enter to drop marker': 'Start - press enter to drop marker',
  'End - press enter to drop marker': 'End - press enter to drop marker',
  'Via point - press enter to drop marker': 'Via point - press enter to drop marker'
};

and register it in src/localization.js?

You could do this in your own new pull request or just send/type translation for me. Then I could test your localization for osrm-text-instructions together with frontend.

yuryleb commented 5 years ago

Translation is also checked with frontend: osrm-hungarian

So if all is ok, maybe this could be merged?

Also IMHO new version of whole package should be released already, maybe maintainers could do this finally?

/cc @1ec5

alexwyattdev commented 5 years ago

Translation is also checked with frontend: osrm-hungarian

So if all is ok, maybe this could be merged?

Also IMHO new version of whole package should be released already, maybe maintainers could do this finally?

/cc @1ec5

It looks and reads correct.

yuryleb commented 5 years ago

Maybe @danpaz could merge this PR?

alexwyattdev commented 5 years ago

Also I already had to write my own logic for correcting a(z) including highway names, since my project needed to proceed further. (Its on android, not js and not regex based)

1ec5 commented 5 years ago

Its on android, not js and not regex based

If you’re using the Mapbox Navigation SDK for Android, note that improvements to OSRM Text Instructions are incorporated into the Mapbox Directions API and therefore the navigation SDK as well. Ideally the navigation SDK would take care of details like this so you don’t have to in your application code.

alexwyattdev commented 5 years ago

An example of special case dor a az: usually highways in hungary starts with an M and then a number and the pronounciation is "emm" so thats why it needs an az before it in this special case.

yuryleb commented 5 years ago

usually highways in hungary starts with an M and then a number and the pronounciation is "emm"

Makes sense 😉

@kiskunk, could you please also answer for my questions above? And also should Hungarian street names be changed together with status names for a grammatical case similar to Russian streets?

alexwyattdev commented 5 years ago

usually highways in hungary starts with an M and then a number and the pronounciation is "emm"

Makes sense 😉

@kiskunk, could you please also answer for my questions above? And also should Hungarian street names be changed together with status names for a grammatical case similar to Russian streets?

So here is a complete list of possible street ending names (i mean like in Boulevard Street where "Street" is the ending) it includes those 11 too from your link.

WayNameEnding[] wayNameEndings = { new WayNameEnding(" ĂĄrok", "ĂĄrkon", "ĂĄrokra"), new WayNameEnding(" ĂĄtjĂĄrĂł", "ĂĄtjĂĄrĂłn", "ĂĄtjĂĄrĂłra"), new WayNameEnding(" dƱlƑ", "dƱlƑn", "dƱlƑre"), new WayNameEnding(" dƱlƑĂșt", "dƱlƑĂșton", "dƱlƑĂștra"), new WayNameEnding(" erdƑsor", "erdƑsoron", "erdƑsorra"), new WayNameEnding(" fasor", "fasoron", "fasorra"), new WayNameEnding(" fordulĂł", "fordulĂłn", "fordulĂłra"), new WayNameEnding(" gĂĄt", "gĂĄton", "gĂĄtra"), new WayNameEnding(" hatĂĄrsor", "hatĂĄrsoron", "hatĂĄrsorra"), new WayNameEnding(" hatĂĄrĂșt", "hatĂĄrĂșton", "hatĂĄrĂștra"), new WayNameEnding(" kapu", "kapun", "kapura"), new WayNameEnding(" körönd", "köröndön", "köröndre"), new WayNameEnding(" körtĂ©r", "körtĂ©ren", "körtĂ©rre"), new WayNameEnding(" körĂșt", "körĂșton", "körĂștra"), new WayNameEnding(" köz", "közön", "közre"), new WayNameEnding(" lakĂłtelep", "lakĂłtelepen", "lakĂłtelepre"), new WayNameEnding(" lejĂĄrĂł", "lejĂĄrĂłn", "lejĂĄrĂłra"), new WayNameEnding(" lejtƑ", "lejtƑn", "lejtƑre"), new WayNameEnding(" lĂ©pcsƑ", "lĂ©pcsƑn", "lĂ©pcsƑre"), new WayNameEnding(" liget", "ligeten", "ligetre"), new WayNameEnding(" mĂ©lyĂșt", "mĂ©lyĂșton", "mĂ©lyĂștra"), new WayNameEnding(" orom", "ormon", "oromra"), new WayNameEnding(" ösvĂ©ny", "ösvĂ©nyen", "ösvĂ©nyre"), new WayNameEnding(" park", "parkon", "parkra"), new WayNameEnding(" part", "parton", "partra"), new WayNameEnding(" pincesor", "pincesoron", "pincesorra"), new WayNameEnding(" rakpart", "rakparton", "rakpartra"), new WayNameEnding(" sĂ©tĂĄny", "sĂ©tĂĄnyon", "sĂ©tĂĄnyra"), new WayNameEnding(" sikĂĄtor", "sikĂĄtoron", "sikĂĄtorra"), new WayNameEnding(" sor", "soron", "sorra"), new WayNameEnding(" sugĂĄrĂșt", "sugĂĄrĂșton", "sugĂĄrĂștra"), new WayNameEnding(" tĂ©r", "tĂ©ren", "tĂ©rre"), new WayNameEnding(" udvar", "udvaron", "udvarra"), new WayNameEnding(" Ășt", "Ășton", "Ăștra"), new WayNameEnding(" utca", "utcĂĄn", "utcĂĄra"), new WayNameEnding(" ĂŒdĂŒlƑpart", "ĂŒdĂŒlƑparton", "ĂŒdĂŒlƑpartra"), new WayNameEnding(" lĂĄnchĂ­d", "lĂĄnchĂ­don", "lĂĄnchĂ­dra"), new WayNameEnding(" hĂ­d", "hĂ­don", "hĂ­dra")};

Grammatical cases as far as i could determine it would require only 2 of ours, but i do not know the name of those cases. the first is the root name, the second is how it changes when you would say "on Boulevard Street", the 3rd is how it would change when you would say "onto Boulevard Street" its a much harder implementation (if even possible) because its based on vowel harmony for 90%, so its not even for 100%... what i put in the translation on transifex solves this issue by using an additional word like if you would say "turn left onto Boulevard Street section"

I think with using the grammar file for standard street names to balance out a/az AND making a rule for M0, M1 ... M85 ... etc would cover almost all except the non-hungarian street names (there are only a few)

For the grammatical cases and the M0..M1 highway names its another dimension of difficulty (at least when the Mapbox SDK tries to read it out loud), because of how it would say the numbers, the numbers also would require a different suffix. For example M0 would be read like "emm nulla" but since we want to use it in context and a sentence, it would be "emm nullĂĄs", and thats not the end because it would still need the "section" word after it (which i think its already there in transifex because its a general translation) or to be better for the ears, the logic from the previous grammar cases, making it into "emm nullĂĄson" or "emm nullĂĄsra", to write this logic it requires to have the numbers 0-20,30,40,50,60,70,80,90,100,200,300.. etc to be defined too with that 2 grammar case, maybe its enough to stay below 1000, i don't think that would come up in any hungarian highway names.

1ec5 commented 5 years ago

For example M0 would be read like "emm nulla" but since we want to use it in context and a sentence, it would be "emm nullĂĄs", and thats not the end because it would still need the "section" word after it (which i think its already there in transifex because its a general translation) or to be better for the ears, the logic from the previous grammar cases, making it into "emm nullĂĄson" or "emm nullĂĄsra", to write this logic it requires to have the numbers 0-20,30,40,50,60,70,80,90,100,200,300.. etc to be defined too with that 2 grammar case, maybe its enough to stay below 1000, i don't think that would come up in any hungarian highway names.

An SSML-aware text-to-speech engine might already handle optimizing numbers or alphanumeric words for speech. (The Mapbox Directions API wraps {way_name} etc. in <speak-as interpret-as="address"> for that reason.) I don’t think OSRM Text Instructions is in a great position to implement number formatting for speech all by itself. That would be a valid feature request against the navigation SDK for when it falls back to the Android TTS engine (since the Mapbox Voice API doesn’t support Hungarian).

what i put in the translation on transifex solves this issue by using an additional word like if you would say "turn left onto Boulevard Street section"

That’s reasonable. The only reason I brought up the grammar file was because of “a(z)”, which a text-to-speech engine is unlikely to pronounce correctly under any circumstance, unfortunately. That said, this PR doesn’t have to be the end of Hungarian localization work. If you think optimizing articles and numbers would be enough of a rabbit hole, we can merge this PR and would welcome any additional contributions regarding grammar.

yuryleb commented 5 years ago

If we're talking about articles change only, it's not too hard to implement here 😉

BTW how a/az should be changed before numbers in phrases like "Megérkezett a(z) 1. célponthoz, a bal oldalon" - I suppose to a everywhere?

But adding 2 grammatical cases support will be not too hard too if we need to change street status name only. @kiskunk, am I understand properly that "turn right onto the street" instruction with DohĂĄny utca street name should look like:

Forduljon be jobbra a Dohåny utcåra felé

And we don't need to change the DohĂĄny name?

alexwyattdev commented 5 years ago

I think a(z) is ok for now. As for jumbers it would be "megérkezett az 1. célponthoz" but "megérkezett a 2. célponthoz" so its atain an another level of complication of what letter the spoken number would start with.

And for the street name it would be: Forduljon jobbra a Dohåny utcåra. without the "felé" and yes Dohåny would not change

yuryleb commented 5 years ago

Ok, please look at first Hungarian grammar rules to handle articles only yet: osrm-hu-articles

Grammar could be extended further to apply grammatical cases to Hungarian street names - I suppose this could be based on analyzing of following magic words after {way_name} & {rotary_name} variables:

@kiskunk, you told about 2 grammatical cases but here are 3 variants - does some of them use the same grammatical case as another (if I'm right in my presumption at all)?

And BTW you seem to forget to include alagĂșt (tunnel) status name into your wayNameEndings list.

alexwyattdev commented 5 years ago

The image looks correct.

My list was from Wikipedia, so i will have to try to update that too with alagĂșt. thanks.

Felé and Irånyåba are interchange-able, they both represent one of the 2 cases, szakaszon represents the other. I just added the other 2 for a little bit of word diversity, I used felé for way_names, and irånyåba for destination.

yuryleb commented 5 years ago

One more question, @kiskunk: how to proceed foreign names - I suppose it's better to keep these felé/irånyåba/szakaszon words on their original place in instructions?

alexwyattdev commented 5 years ago

yes, thats the best way i can imagine

alexwyattdev commented 5 years ago

Yes, I corrected the irĂĄnyĂĄba, and added the missing a(z)

yuryleb commented 5 years ago

OK, now I added support of Sublative and Superessive grammatical cases (yes, they're called so :wink:), please review how this looks on Hungarian streets: 2019-03-24 233112 And on foreign ones: 2019-03-24 232744

alexwyattdev commented 5 years ago

Looks good to me, great job, thanks.