Skip to content
This repository has been archived by the owner on Aug 28, 2024. It is now read-only.

Add translations support #116

Merged
merged 2 commits into from
Nov 11, 2023
Merged

Conversation

brawaru
Copy link
Contributor

@brawaru brawaru commented Oct 23, 2023

Adds support for translations using VIntl module as a peer dependency.

Peer dependencies are dependencies that have to be provided by the
consumer, which means that @vintl/vintl has to be installed and set up
in Theseus and any other consumers.

Translations for Omorphia are done in Omorphia to prevent duplicate
work, and the consumer has to import the locale files like they do for
with the styles already. Those locale files have to be registered in
VIntl plugin and processed using @vintl/unplugin.

@vintl/unplugin is a Unplugin (which means it works with Rollup, Vite,
and even Webpack) that takes in locale files generated by
@formatjs/cli utility and transforms them into the proper ES modules.
This allows consumers to get rid of the intl-messageformat-parser,
which has a huge toll on the bundle size otherwise, at the cost of
inability to parse custom messages.

To give an example of how this can be approached, docs have been updated
to support changing the language used in examples. Knossos is already
doing all this automatically by using @vintl/nuxt.

@formatjs/cli allows to define messages directly and the code and then
automatically extract them into the locale file. Collocation makes it
easier to maintain the messages and see them right in the code.

Translations are done using Crowdin, so Crowdin needs to be connected to
this repository, just like it was connected to Knossos 1. This commit
also introduces a config that allows to do just that.

Footnotes

  1. https://github.com/modrinth/knossos/pull/738#merge-and-integration

@brawaru brawaru force-pushed the feat/enable-translations branch 5 times, most recently from 034aeb9 to 6f3507a Compare October 24, 2023 07:14
@brawaru brawaru marked this pull request as ready for review October 24, 2023 07:16
@Mysterious-Dev
Copy link
Contributor

Mysterious-Dev commented Oct 24, 2023

A small alignment bug, is it due to my config or is it general?

image

@brawaru
Copy link
Contributor Author

brawaru commented Oct 24, 2023

This is not caused by this PR. I can reproduce this on master branch as well.

Adds support for translations using VIntl module as a peer dependency.

Peer dependencies are dependencies that have to be provided by the
consumer, which means that `@vintl/vintl` has to be installed and set up
in Theseus and any other consumers.

Translations for Omorphia are done in Omorphia to prevent duplicate
work, and the consumer has to import the locale files like they do for
with the styles already. Those locale files have to be registered in
VIntl plugin and processed using `@vintl/unplugin`.

`@vintl/unplugin` is a Unplugin (which means it works with Rollup, Vite,
and even Webpack) that takes in locale files generated by
`@formatjs/cli` utility and transforms them into the proper ES modules.
This allows consumers to get rid of the `intl-messageformat-parser`,
which has a huge toll on the bundle size otherwise, at the cost of
inability to parse custom messages.

To give an example of how this can be approached, docs have been updated
to support changing the language used in examples. Knossos is already
doing all this automatically by using `@vintl/nuxt`.

`@formatjs/cli` allows to define messages directly and the code and then
automatically extract them into the locale file. Collocation makes it
easier to maintain the messages and see them right in the code.

Translations are done using Crowdin, so Crowdin needs to be connected to
this repository, just like it was connected to Knossos [^1]. This commit
also introduces a config that allows to do just that.

[^1]: modrinth/knossos#738 (comment)
@triphora triphora merged commit 591ce08 into modrinth:master Nov 11, 2023
1 check passed
@brawaru brawaru deleted the feat/enable-translations branch November 20, 2023 22:28
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Development

Successfully merging this pull request may close these issues.

3 participants