diff --git a/.husky/pre-commit b/.husky/pre-commit new file mode 100755 index 000000000..15f34b6b0 --- /dev/null +++ b/.husky/pre-commit @@ -0,0 +1,4 @@ +#!/bin/sh +. "$(dirname "$0")/_/husky.sh" + +yarn update-l10n-sources diff --git a/i18n/en-US/code.json b/i18n/en-US/code.json new file mode 100644 index 000000000..8291b1051 --- /dev/null +++ b/i18n/en-US/code.json @@ -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" + } +} \ No newline at end of file diff --git a/i18n/en-US/docusaurus-plugin-content-docs/current.json b/i18n/en-US/docusaurus-plugin-content-docs/current.json new file mode 100644 index 000000000..b6f8224cb --- /dev/null +++ b/i18n/en-US/docusaurus-plugin-content-docs/current.json @@ -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" + } +} \ No newline at end of file diff --git a/i18n/en-US/docusaurus-theme-classic/footer.json b/i18n/en-US/docusaurus-theme-classic/footer.json new file mode 100644 index 000000000..9956ea729 --- /dev/null +++ b/i18n/en-US/docusaurus-theme-classic/footer.json @@ -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" + } +} \ No newline at end of file diff --git a/i18n/en-US/docusaurus-theme-classic/navbar.json b/i18n/en-US/docusaurus-theme-classic/navbar.json new file mode 100644 index 000000000..a8c240b20 --- /dev/null +++ b/i18n/en-US/docusaurus-theme-classic/navbar.json @@ -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" + } +} \ No newline at end of file diff --git a/i18n/readme.md b/i18n/readme.md new file mode 100644 index 000000000..07cc79f42 --- /dev/null +++ b/i18n/readme.md @@ -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`. diff --git a/package.json b/package.json index 211dd4c27..bed1630c4 100644 --- a/package.json +++ b/package.json @@ -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", @@ -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", diff --git a/scripts/process-docs-changes.js b/scripts/process-docs-changes.js index 33c347f76..1f6d92d80 100644 --- a/scripts/process-docs-changes.js +++ b/scripts/process-docs-changes.js @@ -38,7 +38,7 @@ const processDocsChanges = async () => { if (output === '') { console.log('Nothing updated, skipping'); return; - } else if (!output.includes('M package.json')) { + } else if (!/M\s+package\.json/.test(output)) { console.log('package.json is not modified, skipping'); return; } else { diff --git a/scripts/update-l10n-sources.js b/scripts/update-l10n-sources.js new file mode 100644 index 000000000..26a468312 --- /dev/null +++ b/scripts/update-l10n-sources.js @@ -0,0 +1,41 @@ +//@ts-check + +/** + * This is a pre-hook task that checks if the files `docusaurus.config.js` or + * `sidebars.js` have been modified and if so makes sure that the files + * needed for localization are regenerated. + */ + +const { getChanges } = require('./utils/git-commands'); +const del = require('del'); +const { execute } = require('./utils/execute'); + +const files = ['docusaurus.config.js', 'sidebars.js']; + +const start = async () => { + console.log(`Checking if the following files have been modified: +${files.join('\n')}`); + const output = await getChanges(); + + const needsRegeneration = files.some((file) => { + return new RegExp(`M\\s+${file}`).test(output); + }); + + if (!needsRegeneration) { + console.log(`No changes found`); + return; + } + + await del('i18n/en-US'); + await execute('yarn write-translations --locale en-US'); + + const localeModified = (await getChanges()) !== ''; + + if(localeModified){ + const pleaseCommit = 'Contents in "/i18n/en-US/" have been modified. Please add the changes to your commit'; + console.error('\x1b[31m%s\x1b', pleaseCommit); + process.exit(1); + } +}; + +start(); diff --git a/yarn.lock b/yarn.lock index f451c1e57..745d23dba 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5807,6 +5807,11 @@ human-signals@^2.1.0: resolved "https://registry.npmjs.org/human-signals/-/human-signals-2.1.0.tgz" integrity sha512-B4FFZ6q/T2jhhksgkbEW3HBvWIfDW85snkQgawt07S7J5QXTk6BkNV+0yAeZrM5QpMAdYlocGoljn0sJ/WQkFw== +husky@^7.0.1: + version "7.0.1" + resolved "https://registry.yarnpkg.com/husky/-/husky-7.0.1.tgz#579f4180b5da4520263e8713cc832942b48e1f1c" + integrity sha512-gceRaITVZ+cJH9sNHqx5tFwbzlLCVxtVZcusME8JYQ8Edy5mpGDOqD8QBCdMhpyo9a+JXddnujQ4rpY2Ff9SJA== + iconv-lite@0.4.24: version "0.4.24" resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.24.tgz#2022b4b25fbddc21d2f524974a474aafe733908b"