i18n-commmune is a tool for developers and translators who work for globalizePJ in Commmune Inc.
Features
To open the translation JSON file corresponding to the component file you are editing, execute "Open Translation File"
For React function components, put cursor on the line where you want to... and execute "Insert useTranslation" command. This will insert import statement and assignment of calling useTranslation with automatically-generated arguments as below:
import React from 'react'
+import { useTranslation } from 'react-i18next'
+const { t } = useTranslation(['components/molecules/admin/settings/integrations'])
For React function components that just return JSX, select code from ( to ) and execute "Insert useTranslation2" to convert function body structure from:
=> (
<>
</>
)
to:
=> {
return (
<>
</>
)
}
and insert import statement and assignment of calling useTranslation with automatically-generated arguments
For React class components, select the class name and execute "Insert withTranslation" command. This will insert import statements and replace the class name with calling withTranslation as below:
import React from 'react'
+import { TFunction } from 'i18next'
+import { withTranslation } from 'react-i18next'
For an item in translation JSON file, select the key value and execute Search All Usages of a Translation Item command. All usages in the corresponding directory will displayed in search result.
Requirements
There is no requirement yet.
Extension Settings
There is no setting yet.
Known Issues
If there is no line which imports react, an error will occur.
Release Notes
0.0.1
Initial release
0.0.2
Take into consideration of the case where import statement imports something else with React
0.1.0
Add command "Open Translation File"
0.1.2
Fix bug
0.2.0
Add command "Insert useTranslation2"
0.3.0
Add command "Initialize Translation File"
0.3.1
Fix return value when findImportReact can not find import statement
0.4.0
Add command "Search All Usages of a Translation Item"
0.4.1
Fix description of 0.4.0 in REAME.md
0.5.0
Modify "Search All Usages of a Translation Item" so that
it works in closed-api-server/ and shared/ as well
it searches translation key with surrounding single quote