File tree Expand file tree Collapse file tree 2 files changed +11
-1
lines changed
libs/astro-nanostores-i18n/src/bin Expand file tree Collapse file tree 2 files changed +11
-1
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ " astro-nanostores-i18n " : patch
3+ ---
4+
5+ Make i18n messages indentifier configurable
Original file line number Diff line number Diff line change @@ -12,6 +12,10 @@ import * as ts from "typescript";
1212const { values } = parseArgs ( {
1313 args : process . argv . slice ( 2 ) ,
1414 options : {
15+ identifier : {
16+ type : "string" ,
17+ default : "messages" ,
18+ } ,
1519 glob : {
1620 type : "string" ,
1721 default : "./src/**/*.astro" ,
@@ -33,6 +37,7 @@ if (values.help) {
3337Usage: extract-messages [options]
3438
3539Options:
40+ --identifier <name> Variable name to extract messages from (default: "messages")
3641 --glob <pattern> Glob pattern for finding Astro files (default: "./src/**/*.astro")
3742 --out <path> Output path for messages file (default: "./src/translations/extract.json")
3843 --help, -h Show this help message
@@ -61,7 +66,7 @@ function extractMessagesFromAST(code: string) {
6166 function visit ( node : ts . Node ) {
6267 if ( ts . isVariableStatement ( node ) ) {
6368 const declaration = node . declarationList . declarations [ 0 ] ;
64- if ( ts . isIdentifier ( declaration . name ) && declaration . name . text === "messages" && declaration . initializer ) {
69+ if ( ts . isIdentifier ( declaration . name ) && declaration . name . text === values . identifier && declaration . initializer ) {
6570 messagesExport = node . getText ( ) ;
6671 }
6772 }
You can’t perform that action at this time.
0 commit comments