@@ -24,17 +24,28 @@ def _formatjs_compile_impl(ctx):
2424 # Build arguments
2525 args = ctx .actions .args ()
2626 args .add ("compile" )
27- args .add (ctx .file . src )
27+ args .add_all (ctx .files . srcs )
2828 args .add ("--out-file" , out_file )
29- args .add ("--format" , ctx .attr .format )
29+
30+ if ctx .attr .format :
31+ args .add ("--format" , ctx .attr .format )
3032
3133 if ctx .attr .ast :
3234 args .add ("--ast" )
3335
36+ if ctx .attr .skip_errors :
37+ args .add ("--skip-errors" )
38+
39+ if ctx .attr .pseudo_locale :
40+ args .add ("--pseudo-locale" , ctx .attr .pseudo_locale )
41+
42+ if ctx .attr .ignore_tag :
43+ args .add ("--ignore-tag" )
44+
3445 ctx .actions .run (
3546 executable = formatjs_cli_info .cli ,
3647 arguments = [args ],
37- inputs = [ ctx .file . src ] ,
48+ inputs = ctx .files . srcs ,
3849 outputs = [out_file ],
3950 mnemonic = "FormatjsCompile" ,
4051 progress_message = "Compiling messages for %{label}" ,
@@ -73,7 +84,7 @@ formatjs_compile = rule(
7384 ```starlark
7485 formatjs_compile(
7586 name = "messages_compiled",
76- src = ":messages", # from formatjs_extract
87+ srcs = [ ":messages"] , # from formatjs_extract
7788 out = "messages.json",
7889 )
7990 ```
@@ -82,17 +93,30 @@ formatjs_compile = rule(
8293 ```starlark
8394 formatjs_compile(
8495 name = "messages_prod",
85- src = "translations/en.json",
96+ srcs = [ "translations/en.json"] ,
8697 out = "compiled-en.json",
8798 ast = True,
8899 )
89100 ```
90101
102+ ### Compile multiple translation files:
103+ ```starlark
104+ formatjs_compile(
105+ name = "messages_merged",
106+ srcs = [
107+ ":base_messages",
108+ "translations/overrides.json",
109+ ],
110+ out = "compiled-messages.json",
111+ ast = True,
112+ )
113+ ```
114+
91115 ### Compile translation files from Crowdin:
92116 ```starlark
93117 formatjs_compile(
94118 name = "fr_messages",
95- src = "translations/fr.json",
119+ srcs = [ "translations/fr.json"] ,
96120 out = "compiled-fr.json",
97121 format = "crowdin",
98122 ast = True,
@@ -117,17 +141,18 @@ formatjs_compile = rule(
117141 - FormatJS CLI documentation: https://formatjs.github.io/docs/tooling/cli
118142 """ ,
119143 attrs = {
120- "src " : attr .label (
121- allow_single_file = [".json" ],
144+ "srcs " : attr .label_list (
145+ allow_files = [".json" ],
122146 mandatory = True ,
123- doc = """Source JSON file with extracted messages.
147+ doc = """Source JSON files with extracted messages.
124148
125- This can be :
126- - Output from `formatjs_extract` rule
127- - Translation file from translators
149+ Can include :
150+ - Multiple outputs from `formatjs_extract` rules
151+ - Multiple translation files from translators
128152 - Aggregated messages from `formatjs_aggregate`
129153
130- The file should contain messages in FormatJS JSON format.
154+ When multiple files are provided, they will be merged during compilation.
155+ The files should contain messages in FormatJS JSON format.
131156 """ ,
132157 ),
133158 "out" : attr .output (
@@ -153,17 +178,48 @@ formatjs_compile = rule(
153178 """ ,
154179 ),
155180 "format" : attr .string (
156- default = "simple" ,
157- values = ["simple" , "crowdin" , "smartling" , "transifex" ],
158181 doc = """Input format of the source file.
159182
160183 Supported formats:
161- - `simple`: Standard FormatJS JSON format (default)
184+ - `default`: Default formatter: extracts defaultMessage from MessageDescriptor objects
185+ - `simple`: Simple formatter: pass-through for Record<string, string>
162186 - `crowdin`: Crowdin translation platform format
163187 - `smartling`: Smartling translation platform format
164188 - `transifex`: Transifex translation platform format
189+ - `lokalise`: Lokalise translation platform format
165190
166191 Use the appropriate format based on your translation management system.
192+ If not specified, uses the default formatter.
193+ """ ,
194+ ),
195+ "skip_errors" : attr .bool (
196+ default = False ,
197+ doc = """Continue compiling after errors.
198+
199+ When enabled, keys with errors are excluded from output but compilation continues.
200+ When disabled (default), compilation fails on the first error.
201+ Useful for partially migrating or dealing with incomplete translations.
202+ """ ,
203+ ),
204+ "pseudo_locale" : attr .string (
205+ doc = """Generate pseudo-locale files for testing.
206+
207+ Requires `ast = True`. Available pseudo-locales:
208+ - `xx-LS`: Longer strings (tests UI expansion)
209+ - `xx-AC`: Accented characters (tests character encoding)
210+ - `xx-HA`: Right-to-left text (tests RTL layout)
211+ - `en-XA`: Accented English
212+ - `en-XB`: Bracketed English
213+
214+ Pseudo-locales help identify i18n issues without actual translations.
215+ """ ,
216+ ),
217+ "ignore_tag" : attr .bool (
218+ default = False ,
219+ doc = """Treat HTML/XML tags as string literals instead of parsing them as tag tokens.
220+
221+ When enabled, tags like `<b>` are treated as plain text rather than formatting tags.
222+ Useful for messages that need to preserve literal tag syntax.
167223 """ ,
168224 ),
169225 },
0 commit comments