File tree Expand file tree Collapse file tree 5 files changed +8
-10
lines changed
src/main/java/com/airsaid/localization Expand file tree Collapse file tree 5 files changed +8
-10
lines changed Original file line number Diff line number Diff line change 55## [ Unreleased]
66### Changed
77- Improve plugin description information.
8+ - Relax translation file name boundaries.
89
910## [ 2.6.1] ( https://github.com/Airsaid/AndroidLocalizePlugin/releases/tag/v2.6.1 ) (2022-08-27)
1011### Added
Original file line number Diff line number Diff line change @@ -25,7 +25,7 @@ Android localization plugin. supports multiple languages and multiple translator
2525- Support to set the translation interval time.
2626
2727# Usage
28- - Step 1: Select the ` values/strings.xml ` (or ` plurals.xml/arrays.xml ` ).
28+ - Step 1: Select the ` values/strings.xml ` (or any string resource in ` values ` directory ).
2929- Step 2: Right click and select "Translate to Other Languages".
3030- Step 3: Select the languages to be translated.
3131- Step 4: Click OK.
Original file line number Diff line number Diff line change @@ -24,7 +24,7 @@ Android 本地化插件,支持多种语言和翻译器。
2424- 支持设置翻译间隔时间。
2525
2626# 使用
27- - 第一步:选择 ` values/strings.xml ` 文件(或者 ` plurals.xml/arrays.xml ` )。
27+ - 第一步:选择 ` values/strings.xml ` 文件(或者是 values 目录下的任何资源文件 )。
2828- 第二步:右键选择:“Translate to Other Languages”。
2929- 第三步:勾选上需要翻译的语言。
3030- 第四步:点击 OK。
Original file line number Diff line number Diff line change @@ -83,7 +83,7 @@ private void showSelectLanguageDialog() {
8383
8484 @ Override
8585 public void update (@ NotNull AnActionEvent e ) {
86- // The translation option is only show when strings. xml/plurals.xml/arrays.xml is selected
86+ // The translation option is only show when xml file from values is selected
8787 Project project = e .getData (CommonDataKeys .PROJECT );
8888 boolean isSelectValueFile = mValueService .isValueFile (e .getData (CommonDataKeys .PSI_FILE ));
8989 e .getPresentation ().setEnabledAndVisible (project != null && isSelectValueFile );
Original file line number Diff line number Diff line change 4343import java .util .ArrayList ;
4444import java .util .Arrays ;
4545import java .util .List ;
46+ import java .util .regex .Pattern ;
4647
4748/**
48- * Operation service for the android value files. eg: strings.xml or plurals.xml or arrays.xml .
49+ * Operation service for the android value files. eg: strings.xml ( or any string resource from values directory) .
4950 *
5051 * @author airsaid
5152 */
@@ -54,9 +55,7 @@ public final class AndroidValuesService {
5455
5556 private static final Logger LOG = Logger .getInstance (AndroidValuesService .class );
5657
57- private static final String NAME_STRINGS_FILE = "strings.xml" ;
58- private static final String NAME_PLURALS_FILE = "plurals.xml" ;
59- private static final String NAME_ARRAYS_FILE = "arrays.xml" ;
58+ private static final Pattern STRINGS_FILE_NAME_PATTERN = Pattern .compile (".+\\ .xml" );
6059
6160 /**
6261 * Returns the {@link AndroidValuesService} object instance.
@@ -154,9 +153,7 @@ public boolean isValueFile(@Nullable PsiFile file) {
154153 if (!"values" .equals (parentName )) return false ;
155154
156155 String fileName = file .getName ();
157- return NAME_STRINGS_FILE .equals (fileName ) ||
158- NAME_PLURALS_FILE .equals (fileName ) ||
159- NAME_ARRAYS_FILE .equals (fileName );
156+ return STRINGS_FILE_NAME_PATTERN .matcher (fileName ).matches ();
160157 }
161158
162159 /**
You can’t perform that action at this time.
0 commit comments