Open erperejildo opened 5 years ago
You can do it here: https://github.com/date-fns/date-fns/blob/master/src/locale/fi/_lib/localize/index.js. I'm wondering what's the difference, could you please request more details on that from the team?
@date-fns/i18n-fi please check this out.
Thanks!
I tried to do the change there directly but I have no src
folder.
Waiting Finnish team response. I'll let you know ASAP
@kossnocorp the difference is: Without TA it's a basic form of the word. The TA ending in Finland is same as OF in front of the month would be in English.
EG: "December" = "Joulukuu"
but "12th of December" = "12 Joulukuuta"
So the translated month separately is fine but it's not when you need to use it on a date.
does this make sense?
btw, link above does't work
Also, it's 12. joulukuuta
to be precise. In Finnish the month names are in lowercase. And the dot there is also meaningful.
Correct @Pyppe. Our phrase in fact is like keskiviikko 30. tammikuu, 1
. Correct my if I'm wrong but it should be keskiviikko 30. tammikuuta, 1
So the translated month separately is fine but it's not when you need to use it on a date.
The equivalent functionality in date-fns is a "formatting" localizer. See here: https://github.com/date-fns/date-fns/blob/master/docs/i18nContributionGuide.md#formatting-localizers
I saw something like that @leshakoss in here: https://github.com/date-fns/date-fns/blob/master/src/locale/fi/_lib/localize/index.js#L24 but not sure how to implement it
dateFNS.format(new Date(), "dddd Do MMMM", { locale: require('date-fns/locale/fi') }) => incorrect('maanantai 28. tammikuu')
dateFNS.format(new Date(), "dddd Do MMMM", { locale: require('date-fns/locale/ru') }) => correct('понедельник 28-е января')
I guess we have similar rules so it should work for both out of the box. Right?
Wait, guys are we talking about date-fns v1?
It is implemented a bit differently in v1 (current master branch and the version that is actively developing is v2). Here is how it works in v1: https://github.com/date-fns/date-fns/blob/v1/src/locale/ru/build_format_locale/index.js#L73-L81
Sorry :). Yep, we are using v1 since it was looking more stable then(v2 is still alpha if I'm right). Correct me if I'm wrong that this functionality just not implemented for Finish language v1 at all..? I couldn't find any functionality similar to Russian language(your link above) and Finish v2 already has this implemented but it's still in alpha. So the most reasonable for us is to fork v1 implementation?
It is not implemented for Finnish language but it could easily be. PRs are welcome. Branch is v1
But if you need it right now and not wait for the new v1 version release (it's kinda cumbersome on our side so it could take a lot of time), you could just monkey patch the locale
@leshakoss sure. After solving this issue locally I will make a PR.
We're trying to make some changes locally but we're facing some issues when we try to build the project. Any steps we need to follow to build this first of all @kossnocorp / @leshakoss ?
@erperejildo do you mean like, build date-fns to copy it to node_modules in your project? If I remember correctly, in v1 the best way to build the package is to remove line npm publish
from scripts/release_npm.sh
and lines git ...
from scripts/release.sh
and then run npm run release
. The built package will be in tmp/npm. Could be wrong, haven't done that in a long time.
Made those changes and this:
$ sh node_modules/date-fns/scripts/release.sh 1.31
yarn run v1.13.0
error Command "sync-versions" not found.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
yarn run v1.13.0
error Command "generate-index" not found.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
yarn run v1.13.0
error Command "build-umd" not found.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
yarn run v1.13.0
error Command "build-docs" not found.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
yarn run v1.13.0
error Command "generate-typings" not found.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
yarn run v1.13.0
error Command "release-npm" not found.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
@erperejildo could you please try running yarn release
instead of sh node_modules/date-fns/scripts/release.sh
?
and from inside date-fns directory. This script is intended for the releasing date-fns that's why what you're trying to do looks a bit hacky
that looks better:
$ yarn release
yarn run v1.13.0
$ ./scripts/release.sh
Done in 1.12s.
So now (and before as well) when I restart my server I get this issue:
[Node] internal/modules/cjs/loader.js:583
[Node] throw err;
[Node] ^
[Node]
[Node] Error: Cannot find module './add_days/index.js'
This again is just V1 forked with these changes: https://github.com/DVELP/date-fns/commit/adb9125eeb85fd51cb0f92c38713e64bf35cf066
As I've already mentioned, the built package should be in tmp/npm
inside date-fns directory. Could you please elaborate why are you trying to build the package? Do you plan to use it like that (I hope not!) or to just test the changes in real life use case?
FYI, in Finnish, months and weekdays are in lower case, e.g., "tammikuu" and "maanantai", but fortunately that was not changed based on OP's feedback.
What concerns me is hard-coding "ta" at the end of wide months and weekdays, as now you need to strip the "ta" away in 99% of the cases.
format(someDate, 'EEEE', { locale: fi }) // outputs 'maanantaita', so it is incorrect in all other scenarios except for the one single scenario discussed above
Regarding this, if there is no date before. For example format(new Date(), 'MMMM') then it should be without the case ending "ta". So "kesäkuu". And not "kesäkuuta".
The case endings here only apply when the "of" prefix is used in english
Now if you want to show only the current, or month and year, it says: "of June 2023" / "Kesäkuuta 2023". Instead of "June 2023" "Kesäkuu 2023" :)
Nevermind, found the LLLL in notes: Notes:
"Formatting" units (e.g. formatting quarter) in the default en-US locale are the same as "stand-alone" units, but are different in some languages. "Formatting" units are declined according to the rules of the language in the context of a date. "Stand-alone" units are always nominative singular:
format(new Date(2017, 10, 6), 'do LLLL', {locale: cs}) //=> '6. listopad'
format(new Date(2017, 10, 6), 'do MMMM', {locale: cs}) //=> '6. listopadu'
Will leave the comment here as this ranks high on google when searching for case ending issues with date-fns formatting
I received from my Finnish team some instructions to change months localization. There should be with a "ta" at the end: "Tammikuu" should be "Tammikuuta" "Lokakuu"" should be "Lokakuuta" etc
How should I change this or any other field?