@payloadcms/translations 3.0.0-beta.0 → 3.0.0-beta.2

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.
package/README.md CHANGED
@@ -1,14 +1,13 @@
1
1
  # Payload Translations
2
2
 
3
- These are the translations for Payload. Translations are used on both the server and the client. The admin panel uses translations to display text to the user in their selected language. The server uses translations when sending API responses.
3
+ The home of Payloads API and Admin Panel translations.
4
4
 
5
5
  ## How to contribute
6
6
 
7
7
  #### Updating a translation
8
8
 
9
- 1. Open the language file you wish to edit located within the `src/all` folder
10
- 2. Update the translation value
11
- 3. Run one of the following:
9
+ 1. Update the translation value
10
+ 2. Run one of the following:
12
11
  ```sh
13
12
  yarn build
14
13
  // or
@@ -19,9 +18,8 @@ These are the translations for Payload. Translations are used on both the server
19
18
 
20
19
  #### Adding a new translation
21
20
 
22
- 1. Add the new translation key/value pair for all languages located in the `src/all` folder
23
- 2. Open the `writeTranslationFiles.ts` file and add the key to either `clientTranslationKeys` or `serverTranslationKeys` depending on where the translation will be used.
24
- 3. Run one of the following:
21
+ 1. Add the new translation key/value pair for **all** languages located in the `<payload-repo-root>/packages/translations/src/languages` folder
22
+ 2. Run one of the following:
25
23
  ```sh
26
24
  yarn build
27
25
  // or
@@ -32,10 +30,9 @@ These are the translations for Payload. Translations are used on both the server
32
30
 
33
31
  #### Adding a new language
34
32
 
35
- 1. Create a new JSON file in the `src/all` folder with the language code as the file name (e.g. `en.json` for English)
36
- 2. Translate all of the keys in the new file
37
- 3. Open the `src/index.ts` file and import your json file and then export it inside the `translations` object
38
- 4. Run one of the following:
33
+ 1. Create a new TS file in the `<payload-repo-root>/packages/translations/src/languages` folder, use the language code as the file name (e.g. `<payload-repo-root>/packages/translations/src/languages/en.ts` for English)
34
+ 2. Copy all translations from an existing language file and update all of the translations to match your new language
35
+ 3. Run one of the following:
39
36
  ```sh
40
37
  yarn build
41
38
  // or
@@ -43,6 +40,8 @@ These are the translations for Payload. Translations are used on both the server
43
40
  // or
44
41
  pnpm build
45
42
  ```
43
+ 4. Import and export your new language file from within `<payload-repo-root>/packages/translations/src/exports/all.ts`
44
+ 5. Re-export the file from within `<payload-repo-root>/packages/payload/src/exports/i18n/[your-new-language].ts`
46
45
 
47
46
  Here is a full list of language keys. Note that these are not all implemented, but if you would like to contribute and add a new language, you can use this list as a reference:
48
47
 
@@ -1,6 +1,6 @@
1
1
  export { importDateFNSLocale } from '../importDateFNSLocale.js';
2
2
  export { getTranslation } from '../utilities/getTranslation.js';
3
3
  export { initI18n, t } from '../utilities/init.js';
4
- export { acceptedLanguages, matchLanguage, rtlLanguages } from '../utilities/languages.js';
4
+ export { acceptedLanguages, extractHeaderLanguage, rtlLanguages } from '../utilities/languages.js';
5
5
  export type * from '../types.js';
6
6
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/exports/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAA;AAC/D,OAAO,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAA;AAC/D,OAAO,EAAE,QAAQ,EAAE,CAAC,EAAE,MAAM,sBAAsB,CAAA;AAClD,OAAO,EAAE,iBAAiB,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AAC1F,mBAAmB,aAAa,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/exports/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAA;AAC/D,OAAO,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAA;AAC/D,OAAO,EAAE,QAAQ,EAAE,CAAC,EAAE,MAAM,sBAAsB,CAAA;AAClD,OAAO,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AAClG,mBAAmB,aAAa,CAAA"}
@@ -1,5 +1,5 @@
1
1
  export { importDateFNSLocale } from '../importDateFNSLocale.js';
2
2
  export { getTranslation } from '../utilities/getTranslation.js';
3
3
  export { initI18n, t } from '../utilities/init.js';
4
- export { acceptedLanguages, matchLanguage, rtlLanguages } from '../utilities/languages.js';
4
+ export { acceptedLanguages, extractHeaderLanguage, rtlLanguages } from '../utilities/languages.js';
5
5
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/exports/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAA;AAC/D,OAAO,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAA;AAC/D,OAAO,EAAE,QAAQ,EAAE,CAAC,EAAE,MAAM,sBAAsB,CAAA;AAClD,OAAO,EAAE,iBAAiB,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/exports/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAA;AAC/D,OAAO,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAA;AAC/D,OAAO,EAAE,QAAQ,EAAE,CAAC,EAAE,MAAM,sBAAsB,CAAA;AAClD,OAAO,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA"}
@@ -1,5 +1,5 @@
1
1
  import type { AcceptedLanguages } from '../types.js';
2
2
  export declare const rtlLanguages: readonly ["ar", "fa"];
3
3
  export declare const acceptedLanguages: readonly ["ar", "az", "bg", "cs", "de", "en", "es", "fa", "fr", "hr", "hu", "it", "ja", "ko", "my", "nb", "nl", "pl", "pt", "ro", "rs", "rsLatin", "ru", "sv", "th", "tr", "uk", "vi", "zh", "zh-TW"];
4
- export declare function matchLanguage(acceptLanguageHeader: string): AcceptedLanguages | undefined;
4
+ export declare function extractHeaderLanguage(acceptLanguageHeader: string): AcceptedLanguages | undefined;
5
5
  //# sourceMappingURL=languages.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"languages.d.ts","sourceRoot":"","sources":["../../src/utilities/languages.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAsB,MAAM,aAAa,CAAA;AAExE,eAAO,MAAM,YAAY,uBAAwB,CAAA;AAEjD,eAAO,MAAM,iBAAiB,uMAiIpB,CAAA;AAkBV,wBAAgB,aAAa,CAAC,oBAAoB,EAAE,MAAM,GAAG,iBAAiB,GAAG,SAAS,CAYzF"}
1
+ {"version":3,"file":"languages.d.ts","sourceRoot":"","sources":["../../src/utilities/languages.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAsB,MAAM,aAAa,CAAA;AAExE,eAAO,MAAM,YAAY,uBAAwB,CAAA;AAEjD,eAAO,MAAM,iBAAiB,uMAiIpB,CAAA;AAkBV,wBAAgB,qBAAqB,CAAC,oBAAoB,EAAE,MAAM,GAAG,iBAAiB,GAAG,SAAS,CAYjG"}
@@ -140,7 +140,7 @@ function parseAcceptLanguage(acceptLanguageHeader) {
140
140
  })
141
141
  .sort((a, b) => b.quality - a.quality); // Sort by quality, highest to lowest
142
142
  }
143
- export function matchLanguage(acceptLanguageHeader) {
143
+ export function extractHeaderLanguage(acceptLanguageHeader) {
144
144
  const parsedHeader = parseAcceptLanguage(acceptLanguageHeader);
145
145
  let matchedLanguage;
146
146
  for (const { language } of parsedHeader) {
@@ -1 +1 @@
1
- {"version":3,"file":"languages.js","sourceRoot":"","sources":["../../src/utilities/languages.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,IAAI,EAAE,IAAI,CAAU,CAAA;AAEjD,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;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AAqC;AAChF,CAAC;AAED,MAAM,UAAU,qBAAqB,CAAC,oBAA4B;IAChE,MAAM,YAAY,GAAG,mBAAmB,CAAC,oBAAoB,CAAC,CAAA;IAE9D,IAAI,eAAkC,CAAA;IAEtC,KAAK,MAAM,EAAE,QAAQ,EAAE,IAAI,YAAY,EAAE,CAAC;QACxC,IAAI,CAAC,eAAe,IAAI,iBAAiB,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC;YAC7D,eAAe,GAAG,QAAQ,CAAA;QAC5B,CAAC;IACH,CAAC;IAED,OAAO,eAAe,CAAA;AACxB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@payloadcms/translations",
3
- "version": "3.0.0-beta.0",
3
+ "version": "3.0.0-beta.2",
4
4
  "main": "./dist/exports/index.js",
5
5
  "types": "./dist/exports/index.d.ts",
6
6
  "type": "module",
@@ -1,5 +1,5 @@
1
1
  export { importDateFNSLocale } from '../importDateFNSLocale.js'
2
2
  export { getTranslation } from '../utilities/getTranslation.js'
3
3
  export { initI18n, t } from '../utilities/init.js'
4
- export { acceptedLanguages, matchLanguage, rtlLanguages } from '../utilities/languages.js'
4
+ export { acceptedLanguages, extractHeaderLanguage, rtlLanguages } from '../utilities/languages.js'
5
5
  export type * from '../types.js'