Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Russian translations are incorrect #312

Closed
iafan opened this Issue · 13 comments

4 participants

@iafan

Just checked samples at http://momentjs.com/ — Russian translations seems to be incorrect: endings of words in Russian differ depending on the context (case), and this also applies to weekdays and month names.

Example from your web site (incorrect):
Russian : В прошлую пятница в 20:44

Correct:
Russian : В прошлую пятниц_у_ в 20:44

Example from your web site (incorrect):
Russian : понедельник, 21 май 2012 20:45

Correct:
Russian : понедельник, 21 ма_я_ 2012_ г.,_ 20:45

@timrwood
Owner

@iafan, what are the rules for when the context changes? Is it based on other parts of the date string?

@Viktorminator wrote the original translation, can you weigh in?

@Viktorminator

hi all! Yes, it seems to be incorrect. So far I was in hurry when done all this.

@iafan

By 'cases' I mean grammatical cases, of course. In Russian, there are a few common ones: Nominative, Accusative, Dative, Genitive, Instrumental, Prepositional, and a handful of rare ones. Here's a good reading: http://www.russianlessons.net/grammar/nouns_nominative.php

I'm not sure how this is expressed in terms of moment.js library, but there seem to be the code that already handles different cases for various date/time parts:

    var format = {
        'mm': 'минута_минуты_минут_минуты',
        'hh': 'час_часа_часов_часа',
        'dd': 'день_дня_дней_дня',
        'MM': 'месяц_месяца_месяцев_месяца',
        'yy': 'год_года_лет_года'
    };

So there should be something like this for week days and month names as well. As @Viktorminator apparently knows Russian, I bet he's already got the idea.

And I'm sorry if I'm hijacking this discussion, but when scanning through the ru.js code, I noticed this:

weekdaysShort : "вск_пнд_втр_срд_чтв_птн_суб".split("_"),

I think it would be better to use two-letter weekday abbreviations, as three-letter ones are not so common in Russia:

weekdaysShort : "вс_пн_вт_ср_чт_пт_сб".split("_"),
@Viktorminator

These guys (

январьфевральмартапрельмайиюньиюльавгустсентябрьоктябрьноябрь_декабрь

in all grammatical cases should be used as these

январяфевралямартаапрелямаяиюняиюляавгустасентябряоктябряноября_декабря

so I think if you change one line - all is going to be fine.
@iafan Do you agree?

@iafan

If month follows the date (e.g. DD MMMM), then it's going to be fine (and this is probably the most common scenario).

In some cases, where the month is the first parameter in the format string (e.g. MMMM YYYY), month names need to stay in nominative case (январь_февраль_...).

@timrwood
Owner

Hmm, the only way to support something with this level of complexity would be to add callbacks for month names.

moment.monthNames = function (momentToFormat, format) {
    // momentToFormat is the current moment being formatted

    // format is the full format string which would need to be 
    //parsed by the lang file to check for grammar situations

    if (shouldUseNominative.test(format)) {
        return nominative[momentToFormat.month()];
    } else {
        return subjective[momentToFormat.month()];
    }
}

I guess this could be done with weekday names as well in case there is a need in the future.

With this context information would you be able to format the strings correctly in Russian?

@iafan

Yes, I think this is a good starting point. I'd only suggest to also pass the position in the format string to indicate which part of the string this callback refers to. This is more for completeness and ability to test parts of the format string more quickly.

@timrwood
Owner

Passing the location in the format string may be a bit of overkill as we would need to compute that every time we format regardless of if it is used by the translation.

If the nominative is only used when the format string starts with 'MMMM', its a pretty easy regex.

moment.monthNames = function (momentToFormat, format) {
    if (/^MMMM/.test(format)) { // starts with 'MMMM'
        return nominative[momentToFormat.month()];
    } else {
        return subjective[momentToFormat.month()];
    }
}
@iafan

I agree, matching against this regex should cover the majority of cases.

@timrwood
Owner

I added the code that should support this. You can check out the feature/add-month-name-callback branch and modify the lang/ru.js and test/lang/ru.js files and then submit a pull request.

This was referenced
@timrwood
Owner

Any update on this?

@timrwood
Owner

This has been merged into the develop branch, so you can write tests and code against that.

@rockymeza

Closed in favor of #343.

@rockymeza rockymeza closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.