Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Inlang to enable community translations / make the contribution of translations easier #662

Merged
merged 9 commits into from
Jan 28, 2023
6 changes: 6 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,9 @@ Framework <http://www.django-rest-framework.org/>`__.

For full documentation, visit `django-rest-framework-simplejwt.readthedocs.io
<https://django-rest-framework-simplejwt.readthedocs.io/en/latest/>`__.


Translations
------------

Contribute translations via inlang https://inlang.com/editor/github.com/jazzband/djangorestframework-simplejwt
Andrew-Chen-Wang marked this conversation as resolved.
Show resolved Hide resolved
47 changes: 47 additions & 0 deletions inlang.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
// filename: inlang.config.js

export async function defineConfig(env) {
// importing a plugin
const plugin = await env.$import(
"https://cdn.jsdelivr.net/gh/jannesblobel/inlang-plugin-po@1/dist/index.js"
);

// most plugins require additional config, read the plugins documentation
// for the required config and correct usage.
const pluginConfig = {
pathPattern:
"./rest_framework_simplejwt/locale/{language}/LC_MESSAGES/django.po",
referenceResourcePath: null,
};

return {
referenceLanguage: "en",
languages: [
Copy link
Member

@Andrew-Chen-Wang Andrew-Chen-Wang Jan 26, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does inlang also make a PR to change this config file when a translator has a new language to add? Want to decrease maintainer effort such that a new issue doesn't need to appear just to ask maintainers to add a new language + use inlang.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not yet, see the ongoing discussion at opral/monorepo#276.

Adding a new language would require modifying the source code. Inlang does not adjust source code right now and thereby eliminates the risk to create bugs in source code. That said, this feature is wanted (upvote it, if you want it too). Needs elaboration on how to implement such a feature.

"en",
"cs",
"de",
"es",
"es_AR",
"es_CL",
"fa_IR",
"fr",
"id_ID",
"it_IT",
"ko_KR",
"nl_NL",
"pl_PL",
"pt_BR",
"ro",
"ru_RU",
"sl",
"sv",
"tr",
"uk_UA",
"zh_Hans",
],
readResources: (args) =>
plugin.readResources({ ...args, ...env, pluginConfig }),
writeResources: (args) =>
plugin.writeResources({ ...args, ...env, pluginConfig }),
};
}