Use dashes instead of underscores in fluent names

This commit is contained in:
Michael Goulet 2022-06-28 21:03:14 -07:00
parent 9b21131278
commit 34d6f08f4d
2 changed files with 8 additions and 4 deletions

View File

@ -1,5 +1,5 @@
builtin_macros-requires-cfg-pattern =
builtin-macros-requires-cfg-pattern =
macro requires a cfg-pattern as an argument
.label = cfg-pattern required
builtin_macros-expected-one-cfg-pattern = expected 1 cfg-pattern
builtin-macros-expected-one-cfg-pattern = expected 1 cfg-pattern

View File

@ -189,9 +189,13 @@ pub(crate) fn fluent_messages(input: proc_macro::TokenStream) -> proc_macro::Tok
if let Entry::Message(Message { id: Identifier { name }, attributes, .. }) = entry {
let _ = previous_defns.entry(name.to_string()).or_insert(ident_span);
// `typeck-foo-bar` => `foo_bar`
// `typeck-foo-bar` => `foo_bar` (in `typeck.ftl`)
// `const-eval-baz` => `baz` (in `const_eval.ftl`)
let snake_name = Ident::new(
&name.replace(&format!("{}-", res.ident), "").replace("-", "_"),
// FIXME: should probably trim prefix, not replace all occurrences
&name
.replace(&format!("{}-", res.ident).replace("_", "-"), "")
.replace("-", "_"),
span,
);
constants.extend(quote! {