Skip to content

Commit

Permalink
feat: add pre-commit hook to keep l10n in sync
Browse files Browse the repository at this point in the history
The locale `i18n/en-US` is used by `electron/i18n` as the source to
translate content into other locales and avoid having to manually create
the different JSON files or keep them in sync.

Once those files are translated, they will be downloaded and put in
the right place for each locale. This will happen in an upcoming PR.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Close #67
Rel: #64
  • Loading branch information
molant committed Jul 14, 2021
1 parent 16c5d4c commit f384250
Show file tree
Hide file tree
Showing 10 changed files with 417 additions and 2 deletions.
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

yarn update-l10n-sources
202 changes: 202 additions & 0 deletions i18n/en-US/code.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,202 @@
{
"theme.NotFound.title": {
"message": "Page Not Found",
"description": "The title of the 404 page"
},
"theme.NotFound.p1": {
"message": "We could not find what you were looking for.",
"description": "The first paragraph of the 404 page"
},
"theme.NotFound.p2": {
"message": "Please contact the owner of the site that linked you to the original URL and let them know their link is broken.",
"description": "The 2nd paragraph of the 404 page"
},
"theme.AnnouncementBar.closeButtonAriaLabel": {
"message": "Close",
"description": "The ARIA label for close button of announcement bar"
},
"theme.blog.paginator.navAriaLabel": {
"message": "Blog list page navigation",
"description": "The ARIA label for the blog pagination"
},
"theme.blog.paginator.newerEntries": {
"message": "Newer Entries",
"description": "The label used to navigate to the newer blog posts page (previous page)"
},
"theme.blog.paginator.olderEntries": {
"message": "Older Entries",
"description": "The label used to navigate to the older blog posts page (next page)"
},
"theme.blog.post.readingTime.plurals": {
"message": "One min read|{readingTime} min read",
"description": "Pluralized label for \"{readingTime} min read\". Use as much plural forms (separated by \"|\") as your language support (see https://www.unicode.org/cldr/cldr-aux/charts/34/supplemental/language_plural_rules.html)"
},
"theme.tags.tagsListLabel": {
"message": "Tags:",
"description": "The label alongside a tag list"
},
"theme.blog.post.readMore": {
"message": "Read More",
"description": "The label used in blog post item excerpts to link to full blog posts"
},
"theme.blog.post.paginator.navAriaLabel": {
"message": "Blog post page navigation",
"description": "The ARIA label for the blog posts pagination"
},
"theme.blog.post.paginator.newerPost": {
"message": "Newer Post",
"description": "The blog post button label to navigate to the newer/previous post"
},
"theme.blog.post.paginator.olderPost": {
"message": "Older Post",
"description": "The blog post button label to navigate to the older/next post"
},
"theme.blog.sidebar.navAriaLabel": {
"message": "Blog recent posts navigation",
"description": "The ARIA label for recent posts in the blog sidebar"
},
"theme.tags.tagsPageTitle": {
"message": "Tags",
"description": "The title of the tag list page"
},
"theme.blog.post.plurals": {
"message": "One post|{count} posts",
"description": "Pluralized label for \"{count} posts\". Use as much plural forms (separated by \"|\") as your language support (see https://www.unicode.org/cldr/cldr-aux/charts/34/supplemental/language_plural_rules.html)"
},
"theme.blog.tagTitle": {
"message": "{nPosts} tagged with \"{tagName}\"",
"description": "The title of the page for a blog tag"
},
"theme.tags.tagsPageLink": {
"message": "View All Tags",
"description": "The label of the link targeting the tag list page"
},
"theme.CodeBlock.copyButtonAriaLabel": {
"message": "Copy code to clipboard",
"description": "The ARIA label for copy code blocks button"
},
"theme.CodeBlock.copied": {
"message": "Copied",
"description": "The copied button label on code blocks"
},
"theme.CodeBlock.copy": {
"message": "Copy",
"description": "The copy button label on code blocks"
},
"theme.docs.sidebar.expandButtonTitle": {
"message": "Expand sidebar",
"description": "The ARIA label and title attribute for expand button of doc sidebar"
},
"theme.docs.sidebar.expandButtonAriaLabel": {
"message": "Expand sidebar",
"description": "The ARIA label and title attribute for expand button of doc sidebar"
},
"theme.docs.paginator.navAriaLabel": {
"message": "Docs pages navigation",
"description": "The ARIA label for the docs pagination"
},
"theme.docs.paginator.previous": {
"message": "Previous",
"description": "The label used to navigate to the previous doc"
},
"theme.docs.paginator.next": {
"message": "Next",
"description": "The label used to navigate to the next doc"
},
"theme.docs.sidebar.collapseButtonTitle": {
"message": "Collapse sidebar",
"description": "The title attribute for collapse button of doc sidebar"
},
"theme.docs.sidebar.collapseButtonAriaLabel": {
"message": "Collapse sidebar",
"description": "The title attribute for collapse button of doc sidebar"
},
"theme.docs.sidebar.responsiveCloseButtonLabel": {
"message": "Close menu",
"description": "The ARIA label for close button of mobile doc sidebar"
},
"theme.docs.sidebar.responsiveOpenButtonLabel": {
"message": "Open menu",
"description": "The ARIA label for open button of mobile doc sidebar"
},
"theme.docs.sidebar.navAriaLabel": {
"message": "Sidebar navigation",
"description": "The ARIA label for documentation menu"
},
"theme.docs.versions.unreleasedVersionLabel": {
"message": "This is unreleased documentation for {siteTitle} {versionLabel} version.",
"description": "The label used to tell the user that he's browsing an unreleased doc version"
},
"theme.docs.versions.unmaintainedVersionLabel": {
"message": "This is documentation for {siteTitle} {versionLabel}, which is no longer actively maintained.",
"description": "The label used to tell the user that he's browsing an unmaintained doc version"
},
"theme.docs.versions.latestVersionSuggestionLabel": {
"message": "For up-to-date documentation, see the {latestVersionLink} ({versionLabel}).",
"description": "The label userd to tell the user that he's browsing an unmaintained doc version"
},
"theme.docs.versions.latestVersionLinkLabel": {
"message": "latest version",
"description": "The label used for the latest version suggestion link label"
},
"theme.common.editThisPage": {
"message": "Edit this page",
"description": "The link label to edit the current page"
},
"theme.common.headingLinkTitle": {
"message": "Direct link to heading",
"description": "Title for link to heading"
},
"theme.lastUpdated.atDate": {
"message": " on {date}",
"description": "The words used to describe on which date a page has been last updated"
},
"theme.lastUpdated.byUser": {
"message": " by {user}",
"description": "The words used to describe by who the page has been last updated"
},
"theme.lastUpdated.lastUpdatedAtBy": {
"message": "Last updated{atDate}{byUser}",
"description": "The sentence used to display when a page has been last updated, and by who"
},
"theme.common.skipToMainContent": {
"message": "Skip to main content",
"description": "The skip to content label used for accessibility, allowing to rapidly navigate to main content with keyboard tab/enter navigation"
},
"theme.SearchPage.documentsFound.plurals": {
"message": "One document found|{count} documents found",
"description": "Pluralized label for \"{count} documents found\". Use as much plural forms (separated by \"|\") as your language support (see https://www.unicode.org/cldr/cldr-aux/charts/34/supplemental/language_plural_rules.html)"
},
"theme.SearchPage.existingResultsTitle": {
"message": "Search results for \"{query}\"",
"description": "The search page title for non-empty query"
},
"theme.SearchPage.emptyResultsTitle": {
"message": "Search the documentation",
"description": "The search page title for empty query"
},
"theme.SearchPage.inputPlaceholder": {
"message": "Type your search here",
"description": "The placeholder for search page input"
},
"theme.SearchPage.inputLabel": {
"message": "Search",
"description": "The ARIA label for search page input"
},
"theme.SearchPage.algoliaLabel": {
"message": "Search by Algolia",
"description": "The ARIA label for Algolia mention"
},
"theme.SearchPage.noResultsText": {
"message": "No results were found",
"description": "The paragraph for empty search result"
},
"theme.SearchPage.fetchingNewResults": {
"message": "Fetching new results...",
"description": "The paragraph for fetching new search results"
},
"theme.SearchBar.label": {
"message": "Search",
"description": "The ARIA label and placeholder for search button"
}
}
70 changes: 70 additions & 0 deletions i18n/en-US/docusaurus-plugin-content-docs/current.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
{
"version.label": {
"message": "Next",
"description": "The label for version current"
},
"sidebar.docs.category.Get Started": {
"message": "Get Started",
"description": "The label for category Get Started in sidebar docs"
},
"sidebar.docs.category.Development": {
"message": "Development",
"description": "The label for category Development in sidebar docs"
},
"sidebar.docs.category.Performance": {
"message": "Performance",
"description": "The label for category Performance in sidebar docs"
},
"sidebar.docs.category.Security": {
"message": "Security",
"description": "The label for category Security in sidebar docs"
},
"sidebar.docs.category.Distribution": {
"message": "Distribution",
"description": "The label for category Distribution in sidebar docs"
},
"sidebar.docs.category.Testing And Debugging": {
"message": "Testing And Debugging",
"description": "The label for category Testing And Debugging in sidebar docs"
},
"sidebar.docs.category.How To": {
"message": "How To",
"description": "The label for category How To in sidebar docs"
},
"sidebar.docs.category.Internals": {
"message": "Internals",
"description": "The label for category Internals in sidebar docs"
},
"sidebar.docs.category.Resources": {
"message": "Resources",
"description": "The label for category Resources in sidebar docs"
},
"sidebar.docs.category.Contributing": {
"message": "Contributing",
"description": "The label for category Contributing in sidebar docs"
},
"sidebar.api.category.Main Process Modules": {
"message": "Main Process Modules",
"description": "The label for category Main Process Modules in sidebar api"
},
"sidebar.api.category.Renderer Process Modules": {
"message": "Renderer Process Modules",
"description": "The label for category Renderer Process Modules in sidebar api"
},
"sidebar.api.category.Custom DOM Elements": {
"message": "Custom DOM Elements",
"description": "The label for category Custom DOM Elements in sidebar api"
},
"sidebar.api.category.Chromium and Node.js": {
"message": "Chromium and Node.js",
"description": "The label for category Chromium and Node.js in sidebar api"
},
"sidebar.api.category.Classes": {
"message": "Classes",
"description": "The label for category Classes in sidebar api"
},
"sidebar.api.category.API Structures": {
"message": "API Structures",
"description": "The label for category API Structures in sidebar api"
}
}
46 changes: 46 additions & 0 deletions i18n/en-US/docusaurus-theme-classic/footer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{
"link.title.Docs": {
"message": "Docs",
"description": "The title of the footer links column with title=Docs in the footer"
},
"link.title.Community": {
"message": "Community",
"description": "The title of the footer links column with title=Community in the footer"
},
"link.title.More": {
"message": "More",
"description": "The title of the footer links column with title=More in the footer"
},
"link.item.label.Getting Started": {
"message": "Getting Started",
"description": "The label of footer link with label=Getting Started linking to /"
},
"link.item.label.Performance": {
"message": "Performance",
"description": "The label of footer link with label=Performance linking to /performance/"
},
"link.item.label.Security": {
"message": "Security",
"description": "The label of footer link with label=Security linking to /security/"
},
"link.item.label.Stack Overflow": {
"message": "Stack Overflow",
"description": "The label of footer link with label=Stack Overflow linking to https://stackoverflow.com/questions/tagged/electron"
},
"link.item.label.Discord": {
"message": "Discord",
"description": "The label of footer link with label=Discord linking to https://discordapp.com/invite/electron"
},
"link.item.label.Twitter": {
"message": "Twitter",
"description": "The label of footer link with label=Twitter linking to https://twitter.com/electronjs"
},
"link.item.label.GitHub": {
"message": "GitHub",
"description": "The label of footer link with label=GitHub linking to https://github.com/electron/electron"
},
"copyright": {
"message": "Copyright © 2021 My Project, Inc. Built with Docusaurus.",
"description": "The footer copyright"
}
}
22 changes: 22 additions & 0 deletions i18n/en-US/docusaurus-theme-classic/navbar.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"title": {
"message": "Electron",
"description": "The title in the navbar"
},
"item.label.Docs": {
"message": "Docs",
"description": "Navbar item with label Docs"
},
"item.label.API": {
"message": "API",
"description": "Navbar item with label API"
},
"item.label.Examples": {
"message": "Examples",
"description": "Navbar item with label Examples"
},
"item.label.GitHub": {
"message": "GitHub",
"description": "Navbar item with label GitHub"
}
}
22 changes: 22 additions & 0 deletions i18n/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# About en-US

**TL;DR;** Do not manually modify the contents of `i18n/en-US`.

Docusaurus translations for anything that is not markdown are stored
in several JSON files. These files are generated for each locale from
the contents of `docusaurus.config.js`, `sidebars.js`, and installed
plugins using the `yarn write-translations --locale [locale]` script.
Some of the files that are generated are `code.json`, `navbar.json`,
`footer.json`, etc.

For the website's source language (`en-US`), these JSON files are **not**
used by Docusaurus. Rather, they serve as source files for our
[Crowdin](https://crowdin.com/project/electron) internationalization (i18n)
workflow. The [`electron/i18n`](https://github.com/electron/i18n) repository
periodically updates these source strings on Crowdin via
[GitHub Actions](https://github.com/electron/i18n/actions/workflows/schedule-update-source-content.yml).

To keep everything in sync, there is a pre-commit hook that automatically
deletes and creates again the `en-US` folder and its contents when
`docusaurus.config.js` or `sidebars.js` are modified.
The script the hook invokes is in `/scripts/update-l10n-sources.js`.
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@
"serve": "docusaurus serve",
"write-translations": "docusaurus write-translations",
"write-heading-ids": "docusaurus write-heading-ids",
"update-l10n-sources": "node scripts/update-l10n-sources.js",
"lint": "prettier -c ./scripts/**/*.js",
"test": "yarn lint && jest",
"prebuild": "node ./scripts/pre-build.js",
"process-docs-changes": "node ./scripts/process-docs-changes.js",
"update-pinned-version": "node ./scripts/update-pinned-version.js"
"update-pinned-version": "node ./scripts/update-pinned-version.js",
"prepare": "husky install"
},
"dependencies": {
"@docusaurus/core": "^2.0.0-beta.3",
Expand Down Expand Up @@ -53,6 +55,7 @@
"globby": "^11.0.3",
"got": "^11.8.2",
"gunzip-maybe": "^1.4.2",
"husky": "^7.0.1",
"jest": "^26.6.3",
"json5": "^2.2.0",
"latest-version": "^5.1.0",
Expand Down
Loading

0 comments on commit f384250

Please sign in to comment.