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

Translations via oarepo tools #63

Merged
merged 2 commits into from
Nov 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions babel.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# -*- coding: utf-8 -*-
#
# This file is part of Invenio.
# Copyright (C) 2015-2018 CERN.
#
# Invenio is free software; you can redistribute it and/or modify it
# under the terms of the MIT License; see LICENSE file for more details.

# Extraction from Python source files

[python: **.py]
encoding = utf-8

# Extraction from Jinja2 templates

[jinja2: **/templates/**.html]
encoding = utf-8

[jinja2: **/templates/**.jinja]
encoding = utf-8

# Special case for jinjax translation strings
[jinja2: **/translations/jinjax_messages.jinja]
encoding = utf-8
33 changes: 33 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
[oarepo.i18n]
languages =
cs
en

# List of paths to scan for babel messages - python files and jinja templates are scanned
babel_source_paths =
models/nr-documents/nr_documents
sites/nr-docs/site
sites/nr-docs/templates
ui/docs-app/docs_app

babel_input_translations =
models/nr-documents/nr_documents/translations
sites/nr-docs/translations
ui/docs-app/docs_app/translations

# List of paths to scan for i18next messages - javascript and jsx files are scanned
i18next_source_paths =
ui/docs-app/docs_app/theme/assets/semantic-ui/js
sites/nr-docs/site/nr_docs/assets/semantic-ui/js

i18next_input_translations =
ui/docs-app/docs_app/theme/assets/semantic-ui/translations/docs_app/messages

# this is the location where python translations are generated.
babel_output_translations =
sites/nr-docs/site/nr_docs/translations

# this is the location where javascript translations are generated. Add this directory to webpack
# aliases
i18next_output_translations =
sites/nr-docs/site/nr_docs/assets/semantic-ui/translations/nr_docs
12 changes: 6 additions & 6 deletions sites/nr-docs/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ Levenshtein==0.23.0
nr-metadata==2.0.2
nr-oaipmh-harvesters==1.0.4
nr-vocabularies==2.0.6
oarepo-oai-pmh-harvester==4.0.36
oarepo-published-service==1.0.1
oarepo-oai-pmh-harvester==4.0.37
oarepo-published-service==1.0.2
oarepo-requests==1.0.2
oarepo-runtime==1.4.23
oarepo-ui==5.0.79
oarepo-vocabularies==2.0.64
oarepo-runtime==1.4.31
oarepo-ui==5.0.82
oarepo-vocabularies==2.0.66
openpyxl==3.1.2
python-dotenv==1.0.0
rapidfuzz==3.5.2
sickle==0.7.0
tqdm==4.66.1
whitenoise==6.6.0
whitenoise==6.6.0
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// This file is part of React-Invenio-Deposit
// Copyright (C) 2021 Graz University of Technology.
//
// Invenio-app-rdm is free software; you can redistribute it and/or modify it
// under the terms of the MIT License; see LICENSE file for more details.

import i18n from "i18next";

import LanguageDetector from "i18next-browser-languagedetector";
import { translations } from "./messages";
import { initReactI18next } from "react-i18next";

const options = {
fallbackLng: "en", // fallback keys
returnEmptyString: false,
debug: process.env.NODE_ENV === "development",
resources: translations,
keySeparator: false,
nsSeparator: false,
// specify language detection order
detection: {
order: ["htmlTag"],
// cache user language off
caches: [],
},
react: {
// Set empty - to allow html tags convert to trans tags
// HTML TAG | Trans TAG
// <span> | <1>
transKeepBasicHtmlNodesFor: [],
},
};

const i18next = i18n.createInstance();
i18next.use(LanguageDetector).use(initReactI18next).init(options);

export { i18next };

Large diffs are not rendered by default.

Loading
Loading