-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: gettext translations (v15 port) (#25982)
* feat: gettext translations + many misc translation fixes Co-Authored-By: Raffael Meyer <raffael@alyf.de> * chore: add crowdin conf * fix: LT fixes * chore: port babel extractors * fix: port get translated country info * fix: dont supress exception in tests * fix!: remove redundant sending of translations * chore: drop docs checker from stable versions * fix: bad usage of _ * fix: translations in webform --------- Co-authored-by: Raffael Meyer <raffael@alyf.de>
- Loading branch information
1 parent
f1c8a99
commit 0189bb2
Showing
36 changed files
with
1,389 additions
and
628 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
hooks.py,frappe.gettext.extractors.navbar.extract | ||
**/doctype/*/*.json,frappe.gettext.extractors.doctype.extract | ||
**/workspace/*/*.json,frappe.gettext.extractors.workspace.extract | ||
**/onboarding_step/*/*.json,frappe.gettext.extractors.onboarding_step.extract | ||
**/module_onboarding/*/*.json,frappe.gettext.extractors.module_onboarding.extract | ||
**/report/*/*.json,frappe.gettext.extractors.report.extract | ||
**.py,frappe.gettext.extractors.python.extract | ||
**.js,frappe.gettext.extractors.javascript.extract | ||
**.html,frappe.gettext.extractors.html_template.extract |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
files: | ||
- source: /frappe/locale/main.pot | ||
translation: /frappe/locale/%two_letters_code%.po | ||
pull_request_title: "fix: sync translations from crowdin" | ||
pull_request_labels: | ||
- translation | ||
commit_message: "fix: %language% translations" | ||
append_commit_message: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
import click | ||
|
||
from frappe.commands import pass_context | ||
from frappe.exceptions import SiteNotSpecifiedError | ||
|
||
|
||
@click.command("generate-pot-file", help="Translation: generate POT file") | ||
@click.option("--app", help="Only generate for this app. eg: frappe") | ||
@pass_context | ||
def generate_pot_file(context, app: str | None = None): | ||
from frappe.gettext.translate import generate_pot | ||
|
||
if not app: | ||
connect_to_site(context.sites[0] if context.sites else None) | ||
|
||
generate_pot(app) | ||
|
||
|
||
@click.command("compile-po-to-mo", help="Translation: compile PO files to MO files") | ||
@click.option("--app", help="Only compile for this app. eg: frappe") | ||
@click.option( | ||
"--force", | ||
is_flag=True, | ||
default=False, | ||
help="Force compile even if there are no changes to PO files", | ||
) | ||
@click.option("--locale", help="Compile transaltions only for this locale. eg: de") | ||
@pass_context | ||
def compile_translations(context, app: str | None = None, locale: str | None = None, force=False): | ||
from frappe.gettext.translate import compile_translations as _compile_translations | ||
|
||
if not app: | ||
connect_to_site(context.sites[0] if context.sites else None) | ||
|
||
_compile_translations(app, locale, force=force) | ||
|
||
|
||
@click.command("migrate-csv-to-po", help="Translation: migrate from CSV files (old) to PO files (new)") | ||
@click.option("--app", help="Only migrate for this app. eg: frappe") | ||
@click.option("--locale", help="Compile translations only for this locale. eg: de") | ||
@pass_context | ||
def csv_to_po(context, app: str | None = None, locale: str | None = None): | ||
from frappe.gettext.translate import migrate | ||
|
||
if not app: | ||
connect_to_site(context.sites[0] if context.sites else None) | ||
|
||
migrate(app, locale) | ||
|
||
|
||
@click.command( | ||
"update-po-files", | ||
help="""Translation: sync PO files with POT file. | ||
You might want to run generate-pot-file first.""", | ||
) | ||
@click.option("--app", help="Only update for this app. eg: frappe") | ||
@click.option("--locale", help="Update PO files only for this locale. eg: de") | ||
@pass_context | ||
def update_po_files(context, app: str | None = None, locale: str | None = None): | ||
from frappe.gettext.translate import update_po | ||
|
||
if not app: | ||
connect_to_site(context.sites[0] if context.sites else None) | ||
|
||
update_po(app, locale=locale) | ||
|
||
|
||
@click.command("create-po-file", help="Translation: create a new PO file for a locale") | ||
@click.argument("locale", nargs=1) | ||
@click.option("--app", help="Only create for this app. eg: frappe") | ||
@pass_context | ||
def create_po_file(context, locale: str, app: str | None = None): | ||
"""Create PO file for lang code""" | ||
from frappe.gettext.translate import new_po | ||
|
||
if not app: | ||
connect_to_site(context.sites[0] if context.sites else None) | ||
|
||
new_po(locale, app) | ||
|
||
|
||
def connect_to_site(site): | ||
from frappe import connect | ||
|
||
if not site: | ||
raise SiteNotSpecifiedError | ||
|
||
connect(site=site) | ||
|
||
|
||
commands = [ | ||
generate_pot_file, | ||
compile_translations, | ||
csv_to_po, | ||
update_po_files, | ||
create_po_file, | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.