Moment: `sk.js`: Fix l10n issues (czechisms)

Created on 12 Mar 2020  ·  16Comments  ·  Source: moment/moment

Describe the bug

The preposition za in the sense of in in in a minute is a czechism (a word or usage borrowed from the Czech language), therefore the moment’s za pár sekúnd is correct in Czech, and incorrect in Slovak. In Slovak, the correct preposition is o in the phrase.

Expected behavior

For example: use o pár second instead of za pár sekúnd (meaning: in a few seconds).


Update: Another issue is the pred 3 dny which should be pred 3 dňami. Not an issue of moment, but of dayjs, my bad.

Help Wanted Language Up-For-Grabs

Most helpful comment

Hm... Perhaps we can distinguish usage between durations and moments. I will leave it open for a little while longer.

All 16 comments

@k2s thoughts?

  1. the statement in this ticket is not true, it is valid slovak language construct
  2. all was discussed here https://github.com/moment/moment/pull/5409#issuecomment-618482801
  3. solution is .replace('za', 'o'), better solution in moment would be to provide context parameter to the translation

@k2s, although my statement in the OP is not _entirely_ correct, it is _partially_ correct. As the current implementation of the issue in Moment. And as the implementation is _not entirely corrent_, I think it should be fixed. I have no idea how, but IMHO the output should be _always_ correct.

Your proposed solution (.replace('za', 'o')) is not even a workaround as it leaves the output _partially_ correct, although reversed.

Based on the sources from your comment in #5409 (which are indeed valid) I have wrote the following in a comment:

  • za is used when we talk about a _period_ during which something is done (like _He cooked it in an hour._);
  • o is used when we talk about a _point in time_ (like _She’s back in a minute._).

Therefore, the current output not correct for o (but correct for za) and if one chooses to use to 'solution', they would get correct output for o, but not for za.

@tukusejssirs thank you that you try to implement and improve support for slovak language in libraries. in relation to moment library, you need to keep in mind that it is established library, used by many projects and to change something has most of all not break existing code.

name of this ticket says that the returned za value is grammatically wrong which would mean it is bug, it would need fix. that is not true.

to correctly return za or o additional context is required which is not needed for english and that, what I am aware of, is not supported by related moment functions

I understand your desire to have it perfect and the way to achieve it is to create moment plugin which will provide methods with context support.

Well, I tried to pass the same: #5206, which was reverted afterwards :-(
I don't believe there are so many Slovak users who would even notice za / o change anyway, so why they keep the incorrect version, I don't understand. Both are valid, though I'd guess that most users need the "in time in future" form, for which o preposition should be used. The form "it took time / it was done in", for which preposition za is used in Slovak, is a much less frequent case.

@dakujem, thanks for your comment. It makes me feel I’m not alone in this. 😄

When I created this PR, I _thought_ we should always use o instead of za, but @k2s proved me wrong (see this comment of mine) that both are correct, but not interchangable.

Therefore from my _current_ point of view, if we use either za only or o only, both are equally wrong as both are _not always true_. I wish I could propose an algorithm (a function) that would deal with the cases when which preposition is to be used, but I am not that good at programming … maybe you can do it. :smiley:

Indeed, both are used. I would bet that o is more frequent though. But...

Unfortunatelly, I'm not a JS guy 🤷, my JS plugin would be bad 😆

@dakujem, currently we don’t need the _code_, but the _algorithm_—how to check what preposition Moment should output?

I don't know how we can distinguish between points in time and periods of time.
I guess I will not make any changes here.

The locales can always be overridden by individual users.
https://momentjs.com/docs/#/customization/

That’s a great pity.

Hm... Perhaps we can distinguish usage between durations and moments. I will leave it open for a little while longer.

It sounds good me.

Is there any way we could get this ‘metadata’ now? Or is it something you need to implement into Moment?

I don't know what you mean.

for now:
If you are using durations, you can update the locale for o.
If you are using moments, it will already use za.

I don't know what you mean.

for now:
If you are using durations, you can update the locale for o.
If you are using moments, it will already use za.

On a second thought, this won’t solve this issue, because in an hour means both o hodinu (like in _I’ll be back in an hour._, which uses o point in time, i.e now + 1 hour) and za hodinu (like in He cooked it in an hour., which talks about a duration of time).

If you still think it’ll solve this issue, please share with me some code snippets how I could distinguish between the two. Thanks.

I read through this discussion again.

It sounds like the difference between za and o depends on the specific context of the sentence. Probably, there are some linguistic texts discussing this, but it sounds more specific than can be implemented in this library. For example, Moment.js cannot distinguish between "He cooked it in an hour" and "I'll be back in an hour".

It seems like the best strategy is to use one, and replace it outside of Moment.js when you need.

If you have other ideas, feel free to re-open. Best of luck!

Moment.js cannot distinguish between "He cooked it in an hour" and "I'll be back in an hour".

@marwahaha, that was my impression, too. It is a pity, but it is true. It’s shame that most l10n tools are so English-concerned that they can’t be modified to _fully_ support other locales. I wish Moment would be like Fluent.

Until then, I think that this is a dead end.

Was this page helpful?
0 / 5 - 0 ratings