@docusaurus/theme-translations 2.0.0-beta.13 → 2.0.0-beta.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (81) hide show
  1. package/lib/index.d.ts +13 -0
  2. package/lib/index.d.ts.map +1 -0
  3. package/lib/index.js +12 -15
  4. package/lib/index.js.map +1 -0
  5. package/locales/ar/plugin-ideal-image.json +7 -0
  6. package/locales/ar/theme-common.json +7 -0
  7. package/locales/ar/theme-search-algolia.json +1 -0
  8. package/locales/base/plugin-ideal-image.json +12 -0
  9. package/locales/base/theme-common.json +13 -0
  10. package/locales/base/theme-search-algolia.json +1 -0
  11. package/locales/bn/plugin-ideal-image.json +7 -0
  12. package/locales/bn/theme-common.json +7 -0
  13. package/locales/bn/theme-search-algolia.json +1 -0
  14. package/locales/cs/plugin-ideal-image.json +7 -0
  15. package/locales/cs/theme-common.json +7 -0
  16. package/locales/cs/theme-search-algolia.json +1 -0
  17. package/locales/da/plugin-ideal-image.json +7 -0
  18. package/locales/da/theme-common.json +7 -0
  19. package/locales/da/theme-search-algolia.json +1 -0
  20. package/locales/de/plugin-ideal-image.json +7 -0
  21. package/locales/de/theme-common.json +7 -0
  22. package/locales/de/theme-search-algolia.json +1 -0
  23. package/locales/es/plugin-ideal-image.json +7 -0
  24. package/locales/es/theme-common.json +7 -0
  25. package/locales/es/theme-search-algolia.json +1 -0
  26. package/locales/fa/plugin-ideal-image.json +7 -0
  27. package/locales/fa/theme-common.json +7 -0
  28. package/locales/fa/theme-search-algolia.json +1 -0
  29. package/locales/fil/plugin-ideal-image.json +7 -0
  30. package/locales/fil/theme-common.json +7 -0
  31. package/locales/fil/theme-search-algolia.json +1 -0
  32. package/locales/fr/plugin-ideal-image.json +7 -0
  33. package/locales/fr/theme-common.json +7 -0
  34. package/locales/fr/theme-search-algolia.json +1 -0
  35. package/locales/he/plugin-ideal-image.json +7 -0
  36. package/locales/he/theme-common.json +7 -0
  37. package/locales/he/theme-search-algolia.json +1 -0
  38. package/locales/hi/plugin-ideal-image.json +7 -0
  39. package/locales/hi/theme-common.json +7 -0
  40. package/locales/hi/theme-search-algolia.json +1 -0
  41. package/locales/it/plugin-ideal-image.json +7 -0
  42. package/locales/it/plugin-pwa.json +5 -0
  43. package/locales/it/theme-common.json +58 -0
  44. package/locales/it/theme-live-codeblock.json +4 -0
  45. package/locales/it/theme-search-algolia.json +12 -0
  46. package/locales/ja/plugin-ideal-image.json +7 -0
  47. package/locales/ja/theme-common.json +7 -0
  48. package/locales/ja/theme-search-algolia.json +1 -0
  49. package/locales/ko/plugin-ideal-image.json +7 -0
  50. package/locales/ko/theme-common.json +9 -2
  51. package/locales/ko/theme-search-algolia.json +1 -0
  52. package/locales/pl/plugin-ideal-image.json +7 -0
  53. package/locales/pl/theme-common.json +7 -0
  54. package/locales/pl/theme-search-algolia.json +1 -0
  55. package/locales/pt-BR/plugin-ideal-image.json +7 -0
  56. package/locales/pt-BR/theme-common.json +7 -0
  57. package/locales/pt-BR/theme-search-algolia.json +1 -0
  58. package/locales/pt-PT/plugin-ideal-image.json +7 -0
  59. package/locales/pt-PT/theme-common.json +7 -0
  60. package/locales/pt-PT/theme-search-algolia.json +1 -0
  61. package/locales/ru/plugin-ideal-image.json +7 -0
  62. package/locales/ru/theme-common.json +7 -0
  63. package/locales/ru/theme-search-algolia.json +1 -0
  64. package/locales/sr/plugin-ideal-image.json +7 -0
  65. package/locales/sr/theme-common.json +7 -0
  66. package/locales/sr/theme-search-algolia.json +1 -0
  67. package/locales/tr/plugin-ideal-image.json +7 -0
  68. package/locales/tr/theme-common.json +7 -0
  69. package/locales/tr/theme-search-algolia.json +1 -0
  70. package/locales/vi/plugin-ideal-image.json +7 -0
  71. package/locales/vi/theme-common.json +7 -0
  72. package/locales/vi/theme-search-algolia.json +1 -0
  73. package/locales/zh-Hans/plugin-ideal-image.json +7 -0
  74. package/locales/zh-Hans/theme-common.json +7 -0
  75. package/locales/zh-Hans/theme-search-algolia.json +1 -0
  76. package/locales/zh-Hant/plugin-ideal-image.json +7 -0
  77. package/locales/zh-Hant/plugin-pwa.json +1 -1
  78. package/locales/zh-Hant/theme-common.json +15 -8
  79. package/locales/zh-Hant/theme-search-algolia.json +2 -1
  80. package/package.json +7 -9
  81. package/src/index.ts +57 -0
@@ -21,12 +21,17 @@
21
21
  "theme.blog.post.paginator.olderPost": "Daha Eski Gönderi",
22
22
  "theme.blog.post.plurals": "Bir gönderi|{count} gönderi",
23
23
  "theme.blog.post.readMore": "Daha Fazla",
24
+ "theme.blog.post.readMoreLabel": "Read more about {title}",
24
25
  "theme.blog.post.readingTime.plurals": "{readingTime} dakikalık okuma|{readingTime} dakikalık okuma",
25
26
  "theme.blog.sidebar.navAriaLabel": "Blog son gönderiler navigasyonu",
26
27
  "theme.blog.tagTitle": "\"{tagName}\" ile etiketlenmiş {nPosts}",
28
+ "theme.colorToggle.ariaLabel": "Switch between dark and light mode (currently {mode})",
29
+ "theme.colorToggle.ariaLabel.mode.light": "light mode",
30
+ "theme.colorToggle.ariaLabel.mode.dark": "dark mode",
27
31
  "theme.common.editThisPage": "Bu sayfayı düzenle",
28
32
  "theme.common.headingLinkTitle": "Başlığa doğrudan bağlantı",
29
33
  "theme.common.skipToMainContent": "Ana içeriğe geç",
34
+ "theme.docs.DocCard.categoryDescription": "{count} items",
30
35
  "theme.docs.paginator.navAriaLabel": "Dokümanlar sayfası navigasyonu",
31
36
  "theme.docs.paginator.next": "Sonraki",
32
37
  "theme.docs.paginator.previous": "Önceki",
@@ -36,6 +41,7 @@
36
41
  "theme.docs.sidebar.expandButtonTitle": "Kenar çubuğunu genişlet",
37
42
  "theme.docs.tagDocListPageTitle": "\"{tagName}\" ile etiketlenmiş {nDocsTagged}",
38
43
  "theme.docs.tagDocListPageTitle.nDocsTagged": "Bir doküman etiketlendi|{count} doküman etiketlendi",
44
+ "theme.docs.versionBadge.label": "Version: {versionLabel}",
39
45
  "theme.docs.versions.latestVersionLinkLabel": "en son sürüm",
40
46
  "theme.docs.versions.latestVersionSuggestionLabel": "Güncel belgeler için bkz. {latestVersionLink} ({versionLabel}).",
41
47
  "theme.docs.versions.unmaintainedVersionLabel": "Bu, {siteTitle} {versionLabel} dokümantasyonudur ve bakımı sonlanmıştır.",
@@ -43,6 +49,7 @@
43
49
  "theme.lastUpdated.atDate": " {date} tarihinde",
44
50
  "theme.lastUpdated.byUser": " {user} tarafından",
45
51
  "theme.lastUpdated.lastUpdatedAtBy": "En son{atDate}{byUser} güncellendi",
52
+ "theme.navbar.mobileLanguageDropdown.label": "Languages",
46
53
  "theme.navbar.mobileSidebarSecondaryMenu.backButtonLabel": "← Ana menüye dön",
47
54
  "theme.navbar.mobileVersionsDropdown.label": "Versiyonlar",
48
55
  "theme.tags.tagsListLabel": "Etiketler:",
@@ -1,5 +1,6 @@
1
1
  {
2
2
  "theme.SearchBar.label": "Ara",
3
+ "theme.SearchBar.seeAll": "See all {count} results",
3
4
  "theme.SearchPage.algoliaLabel": "Algolia ile Ara",
4
5
  "theme.SearchPage.documentsFound.plurals": "Bir döküman bulundu|{count} döküman bulundu",
5
6
  "theme.SearchPage.emptyResultsTitle": "Dokümanlarda ara",
@@ -0,0 +1,7 @@
1
+ {
2
+ "theme.IdealImageMessage.404error": "404. Image not found",
3
+ "theme.IdealImageMessage.error": "Error. Click to reload",
4
+ "theme.IdealImageMessage.load": "Click to load{sizeMessage}",
5
+ "theme.IdealImageMessage.loading": "Loading...",
6
+ "theme.IdealImageMessage.offline": "Your browser is offline. Image not loaded"
7
+ }
@@ -21,12 +21,17 @@
21
21
  "theme.blog.post.paginator.olderPost": "Bài cũ hơn",
22
22
  "theme.blog.post.plurals": "Một bài viết|{count} bài viết",
23
23
  "theme.blog.post.readMore": "Đọc Tiếp",
24
+ "theme.blog.post.readMoreLabel": "Read more about {title}",
24
25
  "theme.blog.post.readingTime.plurals": "Một phút để đọc|{readingTime} phút để đọc",
25
26
  "theme.blog.sidebar.navAriaLabel": "Điều hướng các bài viết gần đây trên blog",
26
27
  "theme.blog.tagTitle": "{nPosts} được gắn thẻ \"{tagName}\"",
28
+ "theme.colorToggle.ariaLabel": "Switch between dark and light mode (currently {mode})",
29
+ "theme.colorToggle.ariaLabel.mode.light": "light mode",
30
+ "theme.colorToggle.ariaLabel.mode.dark": "dark mode",
27
31
  "theme.common.editThisPage": "Sửa trang này",
28
32
  "theme.common.headingLinkTitle": "Đường dẫn trực tiếp tới đề mục này",
29
33
  "theme.common.skipToMainContent": "Nhảy tới nội dung",
34
+ "theme.docs.DocCard.categoryDescription": "{count} items",
30
35
  "theme.docs.paginator.navAriaLabel": "Thanh điều hướng của trang tài liệu",
31
36
  "theme.docs.paginator.next": "Kế tiếp",
32
37
  "theme.docs.paginator.previous": "Trước",
@@ -36,6 +41,7 @@
36
41
  "theme.docs.sidebar.expandButtonTitle": "Mở rộng thanh bên",
37
42
  "theme.docs.tagDocListPageTitle": "{nDocsTagged} với \"{tagName}\"",
38
43
  "theme.docs.tagDocListPageTitle.nDocsTagged": "Một tài liệu đã gắn thẻ|{count} tài liệu đã gắn thẻ",
44
+ "theme.docs.versionBadge.label": "Version: {versionLabel}",
39
45
  "theme.docs.versions.latestVersionLinkLabel": "phiên bản mới nhất",
40
46
  "theme.docs.versions.latestVersionSuggestionLabel": "Để xem các cập nhật mới nhất, vui lòng xem phiên bản {latestVersionLink} ({versionLabel}).",
41
47
  "theme.docs.versions.unmaintainedVersionLabel": "Đây là tài liệu của {siteTitle} {versionLabel}, hiện không còn được bảo trì.",
@@ -43,6 +49,7 @@
43
49
  "theme.lastUpdated.atDate": " vào {date}",
44
50
  "theme.lastUpdated.byUser": " bởi {user}",
45
51
  "theme.lastUpdated.lastUpdatedAtBy": "Cập nhật lần cuối {atDate} bởi {byUser}",
52
+ "theme.navbar.mobileLanguageDropdown.label": "Languages",
46
53
  "theme.navbar.mobileSidebarSecondaryMenu.backButtonLabel": "← Trở lại menu chính",
47
54
  "theme.navbar.mobileVersionsDropdown.label": "Versions",
48
55
  "theme.tags.tagsListLabel": "Thẻ:",
@@ -1,5 +1,6 @@
1
1
  {
2
2
  "theme.SearchBar.label": "Tìm kiếm",
3
+ "theme.SearchBar.seeAll": "See all {count} results",
3
4
  "theme.SearchPage.algoliaLabel": "Tìm kiếm với Algolia",
4
5
  "theme.SearchPage.documentsFound.plurals": "Tìm thấy một kết quả|Tìm thấy {count} kết quả",
5
6
  "theme.SearchPage.emptyResultsTitle": "Tìm kiếm",
@@ -0,0 +1,7 @@
1
+ {
2
+ "theme.IdealImageMessage.404error": "未找到图片",
3
+ "theme.IdealImageMessage.error": "出现错误,点击重试",
4
+ "theme.IdealImageMessage.load": "点击加载图片{sizeMessage}",
5
+ "theme.IdealImageMessage.loading": "加载中……",
6
+ "theme.IdealImageMessage.offline": "你的浏览器处于离线状态。图片未加载"
7
+ }
@@ -21,12 +21,17 @@
21
21
  "theme.blog.post.paginator.olderPost": "较旧一篇",
22
22
  "theme.blog.post.plurals": "{count} 篇博文",
23
23
  "theme.blog.post.readMore": "阅读更多",
24
+ "theme.blog.post.readMoreLabel": "阅读 {title} 的全文",
24
25
  "theme.blog.post.readingTime.plurals": "{readingTime} 分钟阅读",
25
26
  "theme.blog.sidebar.navAriaLabel": "最近博文导航",
26
27
  "theme.blog.tagTitle": "{nPosts} 含有标签「{tagName}」",
28
+ "theme.colorToggle.ariaLabel": "切换浅色/暗黑模式(当前为{mode})",
29
+ "theme.colorToggle.ariaLabel.mode.light": "浅色模式",
30
+ "theme.colorToggle.ariaLabel.mode.dark": "暗黑模式",
27
31
  "theme.common.editThisPage": "编辑此页",
28
32
  "theme.common.headingLinkTitle": "标题的直接链接",
29
33
  "theme.common.skipToMainContent": "跳到主要内容",
34
+ "theme.docs.DocCard.categoryDescription": "{count} 个项目",
30
35
  "theme.docs.paginator.navAriaLabel": "文档分页导航",
31
36
  "theme.docs.paginator.next": "下一页",
32
37
  "theme.docs.paginator.previous": "上一页",
@@ -36,6 +41,7 @@
36
41
  "theme.docs.sidebar.expandButtonTitle": "展开侧边栏",
37
42
  "theme.docs.tagDocListPageTitle": "{nDocsTagged} 篇带有标签「{tagName}」",
38
43
  "theme.docs.tagDocListPageTitle.nDocsTagged": "{count} 篇文档带有标签",
44
+ "theme.docs.versionBadge.label": "版本:{versionLabel}",
39
45
  "theme.docs.versions.latestVersionLinkLabel": "最新版本",
40
46
  "theme.docs.versions.latestVersionSuggestionLabel": "最新的文档请参阅 {latestVersionLink} ({versionLabel})。",
41
47
  "theme.docs.versions.unmaintainedVersionLabel": "此为 {siteTitle} {versionLabel} 版的文档,现已不再积极维护。",
@@ -43,6 +49,7 @@
43
49
  "theme.lastUpdated.atDate": "于 {date} ",
44
50
  "theme.lastUpdated.byUser": "由 {user} ",
45
51
  "theme.lastUpdated.lastUpdatedAtBy": "最后{byUser}{atDate}更新",
52
+ "theme.navbar.mobileLanguageDropdown.label": "选择语言",
46
53
  "theme.navbar.mobileSidebarSecondaryMenu.backButtonLabel": "← 回到主菜单",
47
54
  "theme.navbar.mobileVersionsDropdown.label": "选择版本",
48
55
  "theme.tags.tagsListLabel": "标签:",
@@ -1,5 +1,6 @@
1
1
  {
2
2
  "theme.SearchBar.label": "搜索",
3
+ "theme.SearchBar.seeAll": "查看全部 {count} 个结果",
3
4
  "theme.SearchPage.algoliaLabel": "通过 Algolia 搜索",
4
5
  "theme.SearchPage.documentsFound.plurals": "找到 {count} 份文件",
5
6
  "theme.SearchPage.emptyResultsTitle": "在文档中搜索",
@@ -0,0 +1,7 @@
1
+ {
2
+ "theme.IdealImageMessage.404error": "未找到圖片",
3
+ "theme.IdealImageMessage.error": "出現錯誤,按一下來重試",
4
+ "theme.IdealImageMessage.load": "按一下以載入{sizeMessage}",
5
+ "theme.IdealImageMessage.loading": "載入中...",
6
+ "theme.IdealImageMessage.offline": "你的瀏覽器處於離線狀態。圖片未載入"
7
+ }
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "theme.PwaReloadPopup.closeButtonAriaLabel": "關閉",
3
3
  "theme.PwaReloadPopup.info": "有可用的新版本",
4
- "theme.PwaReloadPopup.refreshButtonText": "刷新"
4
+ "theme.PwaReloadPopup.refreshButtonText": "重新整理"
5
5
  }
@@ -4,15 +4,15 @@
4
4
  "theme.CodeBlock.copied": "複製成功",
5
5
  "theme.CodeBlock.copy": "複製",
6
6
  "theme.CodeBlock.copyButtonAriaLabel": "複製代碼至剪貼簿",
7
- "theme.DocSidebarItem.toggleCollapsedCategoryAriaLabel": "打開/收起側邊欄菜單「{label}」",
8
- "theme.ErrorPageContent.title": "頁面已崩潰。",
7
+ "theme.DocSidebarItem.toggleCollapsedCategoryAriaLabel": "打開/收起側邊欄選單「{label}」",
8
+ "theme.ErrorPageContent.title": "此頁已當機。",
9
9
  "theme.ErrorPageContent.tryAgain": "重試",
10
- "theme.NotFound.p1": "我們找不到您要找的頁面。",
10
+ "theme.NotFound.p1": "我們沒有您要找的頁面。",
11
11
  "theme.NotFound.p2": "請聯絡原始連結來源網站的所有者,並通知他們連結已毀損。",
12
12
  "theme.NotFound.title": "找不到頁面",
13
13
  "theme.TOCCollapsible.toggleButtonLabel": "本頁導覽",
14
- "theme.blog.archive.description": "歷史博文",
15
- "theme.blog.archive.title": "歷史博文",
14
+ "theme.blog.archive.description": "歷史文章",
15
+ "theme.blog.archive.title": "歷史文章",
16
16
  "theme.blog.paginator.navAriaLabel": "部落格文章列表分頁導覽",
17
17
  "theme.blog.paginator.newerEntries": "較新的文章",
18
18
  "theme.blog.paginator.olderEntries": "較舊的文章",
@@ -21,12 +21,17 @@
21
21
  "theme.blog.post.paginator.olderPost": "較舊一篇",
22
22
  "theme.blog.post.plurals": "{count} 篇文章",
23
23
  "theme.blog.post.readMore": "閱讀更多",
24
- "theme.blog.post.readingTime.plurals": "{readingTime} 分鐘閱讀",
24
+ "theme.blog.post.readMoreLabel": "閱讀 {title} 全文",
25
+ "theme.blog.post.readingTime.plurals": "閱讀時間約 {readingTime} 分鐘",
25
26
  "theme.blog.sidebar.navAriaLabel": "最近部落格文章導覽",
26
27
  "theme.blog.tagTitle": "{nPosts} 含有標籤「{tagName}」",
28
+ "theme.colorToggle.ariaLabel": "切換淺色/暗黑模式(當前為{mode})",
29
+ "theme.colorToggle.ariaLabel.mode.light": "淺色模式",
30
+ "theme.colorToggle.ariaLabel.mode.dark": "暗黑模式",
27
31
  "theme.common.editThisPage": "編輯此頁",
28
32
  "theme.common.headingLinkTitle": "標題的直接連結",
29
33
  "theme.common.skipToMainContent": "跳至主要内容",
34
+ "theme.docs.DocCard.categoryDescription": "{count} 個項目",
30
35
  "theme.docs.paginator.navAriaLabel": "文件分頁導覽",
31
36
  "theme.docs.paginator.next": "下一頁",
32
37
  "theme.docs.paginator.previous": "上一頁",
@@ -36,6 +41,7 @@
36
41
  "theme.docs.sidebar.expandButtonTitle": "展開側邊欄",
37
42
  "theme.docs.tagDocListPageTitle": "{nDocsTagged} 篇帶有標籤「{tagName}」",
38
43
  "theme.docs.tagDocListPageTitle.nDocsTagged": "{count} 篇文件帶有標籤",
44
+ "theme.docs.versionBadge.label": "版本:{versionLabel}",
39
45
  "theme.docs.versions.latestVersionLinkLabel": "最新版本",
40
46
  "theme.docs.versions.latestVersionSuggestionLabel": "最新的文件請參閱 {latestVersionLink} ({versionLabel})。",
41
47
  "theme.docs.versions.unmaintainedVersionLabel": "此為 {siteTitle} {versionLabel} 版的文件,現已不再積極維護。",
@@ -43,9 +49,10 @@
43
49
  "theme.lastUpdated.atDate": "於 {date} ",
44
50
  "theme.lastUpdated.byUser": "由 {user} ",
45
51
  "theme.lastUpdated.lastUpdatedAtBy": "最後{byUser}{atDate}更新",
46
- "theme.navbar.mobileSidebarSecondaryMenu.backButtonLabel": "← 回到主菜單",
52
+ "theme.navbar.mobileLanguageDropdown.label": "選擇語言",
53
+ "theme.navbar.mobileSidebarSecondaryMenu.backButtonLabel": "← 回到主選單",
47
54
  "theme.navbar.mobileVersionsDropdown.label": "選擇版本",
48
55
  "theme.tags.tagsListLabel": "標籤:",
49
- "theme.tags.tagsPageLink": "查看所有標籤",
56
+ "theme.tags.tagsPageLink": "檢視所有標籤",
50
57
  "theme.tags.tagsPageTitle": "標籤"
51
58
  }
@@ -1,10 +1,11 @@
1
1
  {
2
2
  "theme.SearchBar.label": "搜尋",
3
+ "theme.SearchBar.seeAll": "查看全部 {count} 個結果",
3
4
  "theme.SearchPage.algoliaLabel": "透過 Algolia 搜尋",
4
5
  "theme.SearchPage.documentsFound.plurals": "找到 {count} 份文件",
5
6
  "theme.SearchPage.emptyResultsTitle": "在文件中搜尋",
6
7
  "theme.SearchPage.existingResultsTitle": "「{query}」的搜尋結果",
7
- "theme.SearchPage.fetchingNewResults": "正在獲取新的搜尋結果...",
8
+ "theme.SearchPage.fetchingNewResults": "正在取得新的搜尋結果...",
8
9
  "theme.SearchPage.inputLabel": "搜尋",
9
10
  "theme.SearchPage.inputPlaceholder": "在此輸入搜尋字詞",
10
11
  "theme.SearchPage.noResultsText": "未找到任何結果"
package/package.json CHANGED
@@ -1,12 +1,9 @@
1
1
  {
2
2
  "name": "@docusaurus/theme-translations",
3
- "version": "2.0.0-beta.13",
3
+ "version": "2.0.0-beta.16",
4
4
  "description": "Docusaurus theme translations.",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
7
- "files": [
8
- "locales"
9
- ],
10
7
  "publishConfig": {
11
8
  "access": "public"
12
9
  },
@@ -19,18 +16,19 @@
19
16
  "scripts": {
20
17
  "build": "tsc",
21
18
  "watch": "tsc --watch",
22
- "update": "node -e 'require(\"./update.js\").run()'"
19
+ "update": "node ./update.js"
23
20
  },
24
21
  "dependencies": {
25
- "fs-extra": "^10.0.0",
22
+ "fs-extra": "^10.0.1",
26
23
  "tslib": "^2.3.1"
27
24
  },
28
25
  "devDependencies": {
29
- "chalk": "^4.1.2",
30
- "lodash": "^4.17.20"
26
+ "@docusaurus/core": "2.0.0-beta.16",
27
+ "@docusaurus/logger": "2.0.0-beta.16",
28
+ "lodash": "^4.17.21"
31
29
  },
32
30
  "engines": {
33
31
  "node": ">=14"
34
32
  },
35
- "gitHead": "b6ca12aedf10a10c2375f4f8b7e7380cfd7c7202"
33
+ "gitHead": "eb43c4d4f95a4fb97dc9bb9dc615413e0dc2e1e7"
36
34
  }
package/src/index.ts ADDED
@@ -0,0 +1,57 @@
1
+ /**
2
+ * Copyright (c) Facebook, Inc. and its affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+
8
+ import path from 'path';
9
+ import fs from 'fs-extra';
10
+
11
+ function getDefaultLocalesDirPath(): string {
12
+ return path.join(__dirname, '../locales');
13
+ }
14
+
15
+ // Return an ordered list of locales we should try
16
+ export function codeTranslationLocalesToTry(locale: string): string[] {
17
+ const intlLocale = new Intl.Locale(locale);
18
+ // if locale is just a simple language like "pt", we want to fallback to pt-BR
19
+ // (not pt-PT!) See https://github.com/facebook/docusaurus/pull/4536#issuecomment-810088783
20
+ if (intlLocale.language === locale) {
21
+ const maximizedLocale = intlLocale.maximize(); // pt-Latn-BR`
22
+ // ["pt","pt-BR"]; ["zh", "zh-Hans"]
23
+ return [
24
+ locale,
25
+ `${maximizedLocale.language}-${maximizedLocale.region}`,
26
+ `${maximizedLocale.language}-${maximizedLocale.script}`,
27
+ ];
28
+ }
29
+ // if locale is like "pt-BR", we want to fallback to "pt"
30
+ return [locale, intlLocale.language!];
31
+ }
32
+
33
+ // Useful to implement getDefaultCodeTranslationMessages() in themes
34
+ export async function readDefaultCodeTranslationMessages({
35
+ dirPath = getDefaultLocalesDirPath(),
36
+ locale,
37
+ name,
38
+ }: {
39
+ dirPath?: string;
40
+ locale: string;
41
+ name: string;
42
+ }): Promise<Record<string, string>> {
43
+ const localesToTry = codeTranslationLocalesToTry(locale);
44
+
45
+ // Return the content of the first file that match
46
+ // fr_FR.json => fr.json => nothing
47
+ for (const localeToTry of localesToTry) {
48
+ const filePath = path.resolve(dirPath, localeToTry, `${name}.json`);
49
+
50
+ if (await fs.pathExists(filePath)) {
51
+ const fileContent = await fs.readFile(filePath, 'utf8');
52
+ return JSON.parse(fileContent);
53
+ }
54
+ }
55
+
56
+ return {};
57
+ }