Learn how to enable translation for numeric values in the Advanced Translation Editor using the WPML configuration file.
Using the WPML configuration file, you can enable numerical values for translation in various pieces of content, such as shortcode attributes and custom fields.
For example, consider two shortcodes, one displaying a slider with texts in English and the other texts in Spanish:
- English –
[custom_slider id = “10”]
- Spanish –
[custom_slider id = “17”]
To correctly display the Spanish slider, we simply need to follow these steps:
- Make the ID attribute translatable in the WPML configuration file.
- Send the page with the slider for translation.
- Set the Spanish slider ID as a translation of the English slider ID in the Advanced Translation Editor: 10 (en) → 17 (es).
XML Configuration
To enable numerical values for translation, you need to use the allow-translatable-job-fields
configuration entry.
Example
<wpml-config>
<allow-translatable-job-fields>
<allow-translatable-job-field type="/^package-string-/" value="/^\d+$/" />
</allow-translatable-job-fields>
</wpml-config>
Arguments Definition
allow-translatable-job-fields
– tag container.allow-translatable-job-field
– child tag (use one for each rule you want to set up).type
– a regular expression for the job field namevalue
– a regular expression for the actual value
In the example above, the type regex /^package-string-/
matches attribute names that follow this prefix, while the value regex /^\d+$/
only allows numeric values.
If you want to enable translation for multiple numerical values, you can include more than one child tag in your configuration.
Example
<wpml-config>
<allow-translatable-job-fields>
<allow-translatable-job-field type="/^package-string-/" value="/^\d+$/" />
<allow-translatable-job-field type="/^field-foo-/" value="/^\d+$/" />
</allow-translatable-job-fields>
</wpml-config>
This configuration allows two different patterns – one for shortcode attributes with package-string-
and another for custom fields starting with field-foo-
.