Difference between revisions of "Resource File(s) Format"
(→Using Custom Resource File Types) |
|||
(15 intermediate revisions by 2 users not shown) | |||
Line 15: | Line 15: | ||
[[What are the Localyzer locales |<== Back to Step 6: What are the Localyzer locales?]] |
[[What are the Localyzer locales |<== Back to Step 6: What are the Localyzer locales?]] |
||
− | |||
== Using Custom Resource File Types == |
== Using Custom Resource File Types == |
||
Line 24: | Line 23: | ||
=== File Name Pattern === |
=== File Name Pattern === |
||
+ | In this following section, the codes used in the file name pattern are based on: |
||
+ | * <code>l</code> is for language, as in ''de'' or ''fr'' or ''zh'' |
||
+ | * <code>c</code> is for country, as in ''DE'' or ''FR'' or ''hant'' |
||
+ | * <code>v</code> is for variant, as in ''tw'' |
||
− | The '''File name pattern''' determines how Localyzer parses locale information from the filename. Both the file name pattern and the file location pattern can be used together, but only one or the other is required. The pattern must contain <code>l</code>, <code>c</code>, and <code>v</code>, or <code>LCID</code>. The pattern cannot contain <code>/</code>, <code>\\</code>, or any letter other than <code>l</code>, <code>c</code>, or <code>v</code>, or the continuous string <code>LCID</code>. The pattern may contain <code>*</code> as a wildcard to indicate “the rest of the file name,” but it must be the very first character of the pattern. Below are some example file name patterns with a hypothetical properties file that they could map to: |
+ | The '''File name pattern''' determines how Localyzer parses locale information from the repository filename. Both the file name pattern and the file location pattern can be used together, but only one or the other is required. The pattern must contain <code>l</code>, <code>c</code>, and <code>v</code>, or <code>LCID</code>. The pattern cannot contain <code>/</code>, <code>\\</code>, or any letter other than <code>l</code>, <code>c</code>, or <code>v</code>, or the continuous string <code>LCID</code>. The pattern may contain <code>*</code> as a wildcard to indicate “the rest of the file name,” but it must be the very first character of the pattern. Below are some example file name patterns with a hypothetical properties file that they could map to: |
<code>*-l_c-v</code> -> <code>file1-zh_hant-tw.properties</code> |
<code>*-l_c-v</code> -> <code>file1-zh_hant-tw.properties</code> |
||
+ | |||
<code>*_l-c-v</code> -> <code>file1_zh-hant-tw.properties</code> |
<code>*_l-c-v</code> -> <code>file1_zh-hant-tw.properties</code> |
||
+ | |||
<code>l_c-v</code> -> <code>zh_hant-tw.properties</code> |
<code>l_c-v</code> -> <code>zh_hant-tw.properties</code> |
||
− | Additionally under the file name pattern column, you have the option to use the pattern on target locale files only, or to also apply the pattern when searching for the base locale files. |
+ | Additionally under the file name pattern column, you have the option to use the pattern on target locale files only, or to also apply the pattern when searching for the base locale files. |
+ | * With '''Targets only''' selected, Localyzer will use any non-target file that matches the include and exclude patterns as a base file. This allows for example <code>file1.properties</code> to be used as a base file even when it has nothing in the name to indicate the locale. |
||
+ | * If '''All locales''' is selected, then the base target files must also obey the locale pattern; for example if your base locale is <code>en_US</code>, then your base target files would have to look something like <code>file1-en_US.properties</code>, depending on how the file name pattern is configured. |
||
=== File Location Pattern === |
=== File Location Pattern === |
||
+ | |||
+ | The file location pattern determines how Localyzer parses locale information from the file directories. Both the file name pattern and the file location pattern can be used together, but only one or the other is required. The pattern must contain <code>l</code>, </code>c</code>, and <code>v</code>, or <code>LCID</code>. The pattern cannot contain <code>\\</code>. Below are some example file name patterns and how they would map to a directory in which the resource files would be located: |
||
+ | |||
+ | <code>*-l_c-v</code> -> <code>values-zh_hant-tw/</code> |
||
+ | |||
+ | <code>*_l-c-v/some/directory</code> -> <code>values_zh-hant-tw/some/directory/</code> |
||
+ | |||
+ | <code>l_c-v/*/abc</code> -> <code>zh_hant-tw/*/abc/</code> |
||
+ | |||
+ | Additionally under the file location pattern column, you have the option to use the pattern on target locale files only, or to also apply the pattern when searching for the base locale files. |
||
+ | * With '''Targets only''' selected, Localyzer will use any non-target file that matches the include and exclude patterns as a base file. This allows, for example <code>values/</code> to be used as a directory for base files even when it has nothing in the name to indicate the locale. |
||
+ | * If '''All locales''' is selected, then the directories that the base target files must also obey the locale pattern; for example if your base locale is <code>en_US</code>, then your base target files would have to be located in a directory something like <code>values-en_US/</code>, depending on how the file location pattern is configured. |
||
=== Extension === |
=== Extension === |
||
+ | |||
+ | The extension is the file extension not including the period. For example, the extension of a resource file <code>file1.properties</code> would be <code>properties</code>. |
||
=== Parser === |
=== Parser === |
||
+ | |||
+ | The parser type can be chosen from any of the parser types built into Localyzer. XML files can be parsed in many different ways, and when the <code>xml</code> parser type is chosen, Localyzer will determine which xml parser to use based on the file extension. |
||
==== Using an XML Parser File ==== |
==== Using an XML Parser File ==== |
||
+ | |||
+ | If a custom xml parser is needed, it can be added to the system as a '''Settings -> System Files -> XML Parser File'''. Then when configuring your resource file type, select the XML parser type. Below the resource file configurations, select '''Use XML parser file''' and then choose the corresponding system file. |
||
=== Encoding === |
=== Encoding === |
||
+ | |||
+ | The file encoding by which to read and write the files. For example: UTF-8 |
||
+ | |||
+ | UTF-8 is the most common encoding value. Select UTF-8 for the encoding unless instructed otherwise. |
||
=== Parameters === |
=== Parameters === |
||
+ | |||
+ | The '''Parameters''' column is a regex pattern that defines how Localyzer parses parameters out of the messages within files. Below are the parameters patterns used in some of the default resource types as examples: |
||
+ | |||
+ | *<code>js</code> - <code>\{\d+\}|%[ds]</code> |
||
+ | *<code>json</code> - <code>\{\w+\}|%[ds]</code> |
||
+ | *<code>msg</code> - <code>%\d+%|%[ds]</code> |
||
+ | *<code>po</code> - <code>%\d*[ds]|%\d+</code> |
||
+ | *<code>properties</code> - <code>\{\w+\}|%[ds]</code> |
||
+ | *<code>rc</code> - <code>%\d+</code> |
||
+ | *<code>strings</code> - <code>%d|%s|%\d+\$s|%\d+\$d|%\{\w+\}</code> |
||
+ | *<code>xml</code> - <code>%[ds]|%\d+\$[ds]|%\{\w+\}</code> |
||
+ | |||
+ | == Custom Transform Scripts == |
||
+ | |||
+ | Custom Transform Scripts are added to the system in '''Settings -> System Files -> Custom Scripts'''. |
||
+ | |||
+ | == Special On-Boarding == |
||
+ | * [[DITA Project Configuration | DITA Project Configuration ]] |
Latest revision as of 15:16, 28 December 2023
Contents
Introduction
- Select the Resource File Types that are to be translated. Verify that the file pattern is correct.
For example if the base resource file is resource.properties
, then the file pattern should be file.properties -> file_fr_FR.properties
.
If the base resource file is resource_en_US.properties
then the file pattern should be file_en_US.properties -> file_fr_FR.properties
.
- Select Use XML parser file or Use custom transform scripts if there are already appropriate files defined in the Setting -> System Files -> XML Parser Files or Transform Folders
Select Next
Step 8: Set up optional include or exclude patterns
<== Back to Step 6: What are the Localyzer locales?
Using Custom Resource File Types
In the event that the file types and patterns in your repository don’t match any of the existing options, custom resource types can be configured. To add a custom resource file type, select the Add resource file format button and choose the custom option. Once added, a new row with many options to customize will appear
File Name Pattern
In this following section, the codes used in the file name pattern are based on:
l
is for language, as in de or fr or zhc
is for country, as in DE or FR or hantv
is for variant, as in tw
The File name pattern determines how Localyzer parses locale information from the repository filename. Both the file name pattern and the file location pattern can be used together, but only one or the other is required. The pattern must contain l
, c
, and v
, or LCID
. The pattern cannot contain /
, \\
, or any letter other than l
, c
, or v
, or the continuous string LCID
. The pattern may contain *
as a wildcard to indicate “the rest of the file name,” but it must be the very first character of the pattern. Below are some example file name patterns with a hypothetical properties file that they could map to:
*-l_c-v
-> file1-zh_hant-tw.properties
*_l-c-v
-> file1_zh-hant-tw.properties
l_c-v
-> zh_hant-tw.properties
Additionally under the file name pattern column, you have the option to use the pattern on target locale files only, or to also apply the pattern when searching for the base locale files.
- With Targets only selected, Localyzer will use any non-target file that matches the include and exclude patterns as a base file. This allows for example
file1.properties
to be used as a base file even when it has nothing in the name to indicate the locale. - If All locales is selected, then the base target files must also obey the locale pattern; for example if your base locale is
en_US
, then your base target files would have to look something likefile1-en_US.properties
, depending on how the file name pattern is configured.
File Location Pattern
The file location pattern determines how Localyzer parses locale information from the file directories. Both the file name pattern and the file location pattern can be used together, but only one or the other is required. The pattern must contain l
, c, and v
, or LCID
. The pattern cannot contain \\
. Below are some example file name patterns and how they would map to a directory in which the resource files would be located:
*-l_c-v
-> values-zh_hant-tw/
*_l-c-v/some/directory
-> values_zh-hant-tw/some/directory/
l_c-v/*/abc
-> zh_hant-tw/*/abc/
Additionally under the file location pattern column, you have the option to use the pattern on target locale files only, or to also apply the pattern when searching for the base locale files.
- With Targets only selected, Localyzer will use any non-target file that matches the include and exclude patterns as a base file. This allows, for example
values/
to be used as a directory for base files even when it has nothing in the name to indicate the locale. - If All locales is selected, then the directories that the base target files must also obey the locale pattern; for example if your base locale is
en_US
, then your base target files would have to be located in a directory something likevalues-en_US/
, depending on how the file location pattern is configured.
Extension
The extension is the file extension not including the period. For example, the extension of a resource file file1.properties
would be properties
.
Parser
The parser type can be chosen from any of the parser types built into Localyzer. XML files can be parsed in many different ways, and when the xml
parser type is chosen, Localyzer will determine which xml parser to use based on the file extension.
Using an XML Parser File
If a custom xml parser is needed, it can be added to the system as a Settings -> System Files -> XML Parser File. Then when configuring your resource file type, select the XML parser type. Below the resource file configurations, select Use XML parser file and then choose the corresponding system file.
Encoding
The file encoding by which to read and write the files. For example: UTF-8
UTF-8 is the most common encoding value. Select UTF-8 for the encoding unless instructed otherwise.
Parameters
The Parameters column is a regex pattern that defines how Localyzer parses parameters out of the messages within files. Below are the parameters patterns used in some of the default resource types as examples:
js
-\{\d+\}|%[ds]
json
-\{\w+\}|%[ds]
msg
-%\d+%|%[ds]
po
-%\d*[ds]|%\d+
properties
-\{\w+\}|%[ds]
rc
-%\d+
strings
-%d|%s|%\d+\$s|%\d+\$d|%\{\w+\}
xml
-%[ds]|%\d+\$[ds]|%\{\w+\}
Custom Transform Scripts
Custom Transform Scripts are added to the system in Settings -> System Files -> Custom Scripts.