-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(@formatjs/cli): add lokalise, crowdin, lingohub, phrase formatter
- Loading branch information
Showing
12 changed files
with
295 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import {FormatFn, CompileFn} from '../..'; | ||
|
||
export type SmartlingJson = Record< | ||
string, | ||
{ | ||
message: string; | ||
description?: string; | ||
} | ||
>; | ||
|
||
export const format: FormatFn<SmartlingJson> = msgs => { | ||
const results: SmartlingJson = {}; | ||
for (const [id, msg] of Object.entries(msgs)) { | ||
results[id] = { | ||
message: msg.defaultMessage!, | ||
description: msg.description, | ||
}; | ||
} | ||
return results; | ||
}; | ||
|
||
export const compile: CompileFn<SmartlingJson> = msgs => { | ||
const results: Record<string, string> = {}; | ||
for (const [id, msg] of Object.entries(msgs)) { | ||
if (id === 'smartling') { | ||
continue; | ||
} | ||
results[id] = msg.message; | ||
} | ||
return results; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import {FormatFn, CompileFn} from '../..'; | ||
|
||
export type StructuredJson = Record< | ||
string, | ||
{ | ||
translation: string; | ||
notes?: string; | ||
context?: string; | ||
limit?: string; | ||
} | ||
>; | ||
|
||
export const format: FormatFn<StructuredJson> = msgs => { | ||
const results: StructuredJson = {}; | ||
for (const [id, msg] of Object.entries(msgs)) { | ||
results[id] = { | ||
translation: msg.defaultMessage!, | ||
notes: msg.description, | ||
}; | ||
} | ||
return results; | ||
}; | ||
|
||
export const compile: CompileFn<StructuredJson> = msgs => { | ||
const results: Record<string, string> = {}; | ||
for (const [id, msg] of Object.entries(msgs)) { | ||
results[id] = msg.translation; | ||
} | ||
return results; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import {FormatFn, CompileFn} from '../..'; | ||
|
||
export type PhraseJson = Record<string, string>; | ||
|
||
export const format: FormatFn<PhraseJson> = msgs => { | ||
return Object.keys(msgs).reduce((all: PhraseJson, k) => { | ||
all[k] = msgs[k].defaultMessage!; | ||
return all; | ||
}, {}); | ||
}; | ||
|
||
export const compile: CompileFn<PhraseJson> = msgs => msgs; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"ashd2": { | ||
"message": "a message", | ||
"description": "foo" | ||
}, | ||
"a1dd2": { | ||
"message": "my name is {name}", | ||
"description": "foo" | ||
}, | ||
"a1d12": { | ||
"message": "I have {count, plural, one{a dog} other{many dogs}}", | ||
"description": "foo" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"ashd2": { | ||
"translation": "a message", | ||
"notes": "foo" | ||
}, | ||
"a1dd2": { | ||
"translation": "my name is {name}", | ||
"notes": "foo" | ||
}, | ||
"a1d12": { | ||
"translation": "I have {count, plural, one{a dog} other{many dogs}}", | ||
"notes": "foo" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"ashd2": "a message", | ||
"a1dd2": "my name is {name}", | ||
"a1d12": "I have {count, plural, one{a dog} other{many dogs}}" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters