Skip to content

Commit

Permalink
Fix Translate component within variable declaration (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
rtsao committed Aug 3, 2023
1 parent c7adedb commit b8eb3ae
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 0 deletions.
3 changes: 3 additions & 0 deletions fixtures/i18n-var-translate-component/code.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { Translate } from "fusion-plugin-i18n-react";

const Foo = <Translate id="foo" />;
3 changes: 3 additions & 0 deletions fixtures/i18n-var-translate-component/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"ssr": true
}
8 changes: 8 additions & 0 deletions fixtures/i18n-var-translate-component/output.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import _fusionPluginI18nChunkTranslationMap from "virtual:fusion-vite-i18n-map";
import { Translate } from "fusion-plugin-i18n-react";
const Foo = <Translate id="foo" />;
_fusionPluginI18nChunkTranslationMap.add("/path/to/file.js", [
"vite-i18n-chunk"
], [
"foo"
]);
1 change: 1 addition & 0 deletions packages/fusion/transform/src/i18n/analyze_imports.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ impl Visit for Analyzer<'_> {
noop_visit_type!();

fn visit_var_declarator(&mut self, var_declarator: &VarDeclarator) {
var_declarator.visit_children_with(self);
if let Some(name) = get_var_name(var_declarator) {
if let Some(init_val) = var_declarator.init.as_ref() {
match &**init_val {
Expand Down

0 comments on commit b8eb3ae

Please sign in to comment.