@chesterbrains/translify-cli 0.6.0 → 0.6.1

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
@@ -128,7 +128,9 @@ server converts both ways:
128
128
  { "files": [{ "pattern": "src/locale/messages.{locale}.xlf", "format": "xliff", "namespace": "web", "xliffDialect": "angular" }] }
129
129
  ```
130
130
 
131
- Give every template string `i18n="@@<key>"` so the unit ids are your keys. What `pull` writes:
131
+ Give every template string `i18n="@@<key>"` so the unit ids are your keys. A translation file's `trgLang` must be the
132
+ Translify locale code: with `"locales": { "it": "it-IT" }` the file is still `messages.it.xlf`, but it declares
133
+ `trgLang="it-IT"`, or `push` is refused with `File targets it but it-IT was requested`. What `pull` writes:
132
134
 
133
135
  | Translify value | Angular unit |
134
136
  |---|---|
@@ -217,7 +219,7 @@ fields are refused, and so is any field whose name contains `key`, `secret` or `
217
219
  | `files[].jsonStyle` | `nested` \| `flat` | no | Only for `json`. `nested` (the default) writes `{ "a": { "b": "…" } }`, `flat` writes `{ "a.b": "…" }`. |
218
220
  | `files[].xliffDialect` | `angular` \| `xcode` | no | Only for `xliff`. `angular` writes `@angular/localize` placeholders on pull and reads `ng extract-i18n` output on push ([Angular (XLIFF)](#angular-xliff)); `xcode` writes XLIFF 1.2 for String Catalogs and reads `xcodebuild -exportLocalizations` output ([Xcode (XLIFF)](#xcode-xliff)). |
219
221
  | `files[].xliffOriginal` | string | with `xliffDialect: "xcode"` | The String Catalog path Xcode knows, e.g. `Sources/App/Localizable.xcstrings`; written to `<file original>`. Xcode imports nothing when it does not match the project. Only with `xcode`. |
220
- | `locales` | object | no | Maps a locale name on disk to a Translify locale code, e.g. `{ "en_US": "en-US" }`. Unmapped names pass through unchanged. Two names may not map to the same code, and a target may not itself be a mapped name. |
222
+ | `locales` | object | no | Maps a locale name on disk to a Translify locale code, e.g. `{ "en_US": "en-US" }`. Unmapped names pass through unchanged. Two names may not map to the same code, and a target may not itself be a mapped name. The map renames files only: an XLIFF's `trgLang` (2.0) or `target-language` (1.2), when present, must be the Translify code itself, or `push` is refused with `File targets it but it-IT was requested`. |
221
223
 
222
224
  Each file must be matched by one rule only, and each (locale, namespace) pair must come from one file only;
223
225
  otherwise the CLI stops before sending anything and names the files involved.
@@ -10,6 +10,7 @@ export function credentialsPath(env = process.env) {
10
10
  return join(appData, 'translify', 'credentials');
11
11
  return join(absolute(env.XDG_CONFIG_HOME) ?? join(homedir(), '.config'), 'translify', 'credentials');
12
12
  }
13
+ const SECRET_KEY_SHAPE = /^sk_[A-Za-z0-9_-]+$/;
13
14
  // Messages never echo the value: a mistyped key is still a secret.
14
15
  export const assertSecret = (key) => {
15
16
  if (key.startsWith('pk_')) {
@@ -17,6 +18,11 @@ export const assertSecret = (key) => {
17
18
  }
18
19
  if (!key.startsWith('sk_'))
19
20
  throw new CliError(EXIT.auth, 'Not a Translify secret key (expected sk_...).');
21
+ // A key is `sk_` plus base64url. Anything else (a pasted `…`, a space, a `/`) is caught here: fetch
22
+ // would refuse it as a header value, which reads as a connection error (TRLIFY-128).
23
+ if (!SECRET_KEY_SHAPE.test(key)) {
24
+ throw new CliError(EXIT.auth, 'The key has characters a secret key never has (only letters, digits, - and _ after sk_). Check TRANSLIFY_SECRET_KEY.');
25
+ }
20
26
  return key;
21
27
  };
22
28
  export async function resolveKey(env = process.env) {
package/dist/version.js CHANGED
@@ -1,3 +1,3 @@
1
1
  // Must equal package.json "version"; src/version.test.ts fails when they drift.
2
- export const VERSION = '0.6.0';
2
+ export const VERSION = '0.6.1';
3
3
  export const USER_AGENT = `translify-cli/${VERSION}`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chesterbrains/translify-cli",
3
- "version": "0.6.0",
3
+ "version": "0.6.1",
4
4
  "description": "Push, pull and publish Translify translations from your repository",
5
5
  "license": "MIT",
6
6
  "repository": {