Source locale is not excluded in target file mappings
Description
Environment
Activity
Former user 5 April 2017 at 06:13
It's a bug introduced by this commit fad3d89d8ce937abda8e1ef9920b69648e8d8fb3
The bug is in file org.zanata.client.commands.pull.PropertiesStrategy
@DanielO for now looks like the only way is to use the command hook workaround I suggested in previous comment
Carlos Munoz 5 April 2017 at 02:05
Hmm... the rules work like they should work. Patrick what do you think?
DanielO 4 April 2017 at 07:14
@Former user here's my config file:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<config xmlns="http://zanata.org/namespace/config/">
<url>http://xxxxxxxxxxxxx/zanata/</url>
<project>idealista</project>
<project-version>TRAD-1212_LISTINGS</project-version>
<project-type>utf8properties</project-type>
<src-dir>src/main/resources/conf/i18n</src-dir>
<trans-dir>src/main/resources/conf/i18n</trans-dir>
<locales>
<locale map-from='ca'>ca-ES</locale>
<locale map-from='fr'>fr-FR</locale>
<locale map-from='it'>it-IT</locale>
<locale map-from='de'>de-DE</locale>
<locale map-from='en'>en-GB</locale>
<locale map-from='pt'>pt-PT</locale>
</locales>
<rules>
<rule pattern="**/seo-es-specific_es.properties">{path}/seo-es-specific_{locale}.{extension}</rule>
<rule pattern="**/info-es-specific_es.properties">{path}/info-es-specific_{locale}.{extension}</rule>
<rule pattern="**/breadcrumb-es-specific_es.properties">{path}/breadcrumb-es-specific_{locale}.{extension}</rule>
<rule pattern="**/alert-es-specific_es.properties">{path}/alert-es-specific_{locale}.{extension}</rule>
<rule pattern="**/home-es-specific_es.properties">{path}/home-es-specific_{locale}.{extension}</rule>
<rule pattern="**/detail-es-specific_es.properties">{path}/detail-es-specific_{locale}.{extension}</rule>
<rule pattern="**/adspublication-es-specific_es.properties">{path}/adspublication-es-specific_{locale}.{extension}</rule>
<rule pattern="**/adsmanagement-es-specific_es.properties">{path}/adsmanagement-es-specific_{locale}.{extension}</rule>
<rule pattern="**/listings-es-specific_es.properties">{path}/listings-es-specific_{locale}.{extension}</rule>
<rule pattern="**/pricepolicy-es-specific_es.properties">{path}/pricepolicy-es-specific_{locale}.{extension}</rule>
<rule pattern="**/footer-es-specific_es.properties">{path}/footer-es-specific_{locale}.{extension}</rule>
<rule pattern="**/search-es-specific_es.properties">{path}/search-es-specific_{locale}.{extension}</rule>
<rule pattern="**/messages-es-specific_es.properties">{path}/messages-es-specific_{locale}.{extension}</rule>
<rule pattern="**/cookiespolicy-es-specific_es.properties">{path}/cookiespolicy-es-specific_{locale}.{extension}</rule>
<rule pattern="**/mortgages-es-specific_es.properties">{path}/mortgages-es-specific_{locale}.{extension}</rule>
<rule pattern="**/cee-es-specific_es.properties">{path}/cee-es-specific_{locale}.{extension}</rule>
<rule pattern="**/phonesinput-es-specific_es.properties">{path}/phonesinput-es-specific_{locale}.{extension}</rule>
<rule pattern="**/seo-it-specific_es.properties">{path}/seo-it-specific_{locale}.{extension}</rule>
<rule pattern="**/info-it-specific_es.properties">{path}/info-it-specific_{locale}.{extension}</rule>
<rule pattern="**/breadcrumb-it-specific_es.properties">{path}/breadcrumb-it-specific_{locale}.{extension}</rule>
<rule pattern="**/alert-it-specific_es.properties">{path}/alert-it-specific_{locale}.{extension}</rule>
<rule pattern="**/home-it-specific_es.properties">{path}/home-it-specific_{locale}.{extension}</rule>
<rule pattern="**/detail-it-specific_es.properties">{path}/detail-it-specific_{locale}.{extension}</rule>
<rule pattern="**/adspublication-it-specific_es.properties">{path}/adspublication-it-specific_{locale}.{extension}</rule>
<rule pattern="**/adsmanagement-it-specific_es.properties">{path}/adsmanagement-it-specific_{locale}.{extension}</rule>
<rule pattern="**/listings-it-specific_es.properties">{path}/listings-it-specific_{locale}.{extension}</rule>
<rule pattern="**/pricepolicy-it-specific_es.properties">{path}/pricepolicy-it-specific_{locale}.{extension}</rule>
<rule pattern="**/footer-it-specific_es.properties">{path}/footer-it-specific_{locale}.{extension}</rule>
<rule pattern="**/search-it-specific_es.properties">{path}/search-it-specific_{locale}.{extension}</rule>
<rule pattern="**/messages-it-specific_es.properties">{path}/messages-it-specific_{locale}.{extension}</rule>
<rule pattern="**/cookiespolicy-it-specific_es.properties">{path}/cookiespolicy-it-specific_{locale}.{extension}</rule>
<rule pattern="**/mortgages-it-specific_es.properties">{path}/mortgages-it-specific_{locale}.{extension}</rule>
<rule pattern="**/cee-it-specific_es.properties">{path}/cee-it-specific_{locale}.{extension}</rule>
<rule pattern="**/phonesinput-it-specific_es.properties">{path}/phonesinput-it-specific_{locale}.{extension}</rule>
<rule pattern="**/seo-pt-specific_es.properties">{path}/seo-pt-specific_{locale}.{extension}</rule>
<rule pattern="**/info-pt-specific_es.properties">{path}/info-pt-specific_{locale}.{extension}</rule>
<rule pattern="**/breadcrumb-pt-specific_es.properties">{path}/breadcrumb-pt-specific_{locale}.{extension}</rule>
<rule pattern="**/alert-pt-specific_es.properties">{path}/alert-pt-specific_{locale}.{extension}</rule>
<rule pattern="**/home-pt-specific_es.properties">{path}/home-pt-specific_{locale}.{extension}</rule>
<rule pattern="**/detail-pt-specific_es.properties">{path}/detail-pt-specific_{locale}.{extension}</rule>
<rule pattern="**/adspublication-pt-specific_es.properties">{path}/adspublication-pt-specific_{locale}.{extension}</rule>
<rule pattern="**/adsmanagement-pt-specific_es.properties">{path}/adsmanagement-pt-specific_{locale}.{extension}</rule>
<rule pattern="**/listings-pt-specific_es.properties">{path}/listings-pt-specific_{locale}.{extension}</rule>
<rule pattern="**/pricepolicy-pt-specific_es.properties">{path}/pricepolicy-pt-specific_{locale}.{extension}</rule>
<rule pattern="**/footer-pt-specific_es.properties">{path}/footer-pt-specific_{locale}.{extension}</rule>
<rule pattern="**/search-pt-specific_es.properties">{path}/search-pt-specific_{locale}.{extension}</rule>
<rule pattern="**/messages-pt-specific_es.properties">{path}/messages-pt-specific_{locale}.{extension}</rule>
<rule pattern="**/cookiespolicy-pt-specific_es.properties">{path}/cookiespolicy-pt-specific_{locale}.{extension}</rule>
<rule pattern="**/mortgages-pt-specific_es.properties">{path}/mortgages-pt-specific_{locale}.{extension}</rule>
<rule pattern="**/cee-pt-specific_es.properties">{path}/cee-pt-specific_{locale}.{extension}</rule>
<rule pattern="**/phonesinput-pt-specific_es.properties">{path}/phonesinput-pt-specific_{locale}.{extension}</rule>
<rule pattern="**/messages_es.properties">{path}/messages_{locale}.{extension}</rule>
<rule pattern="**/home_es.properties">{path}/home_{locale}.{extension}</rule>
<rule pattern="**/adspublication_es.properties">{path}/adspublication_{locale}.{extension}</rule>
<rule pattern="**/search_es.properties">{path}/search_{locale}.{extension}</rule>
<rule pattern="**/listings_es.properties">{path}/listings_{locale}.{extension}</rule>
<rule pattern="**/users_es.properties">{path}/users_{locale}.{extension}</rule>
<rule pattern="**/userdata_es.properties">{path}/userdata_{locale}.{extension}</rule>
<rule pattern="**/mortgages_es.properties">{path}/mortgages_{locale}.{extension}</rule>
<rule pattern="**/adsmanagement_es.properties">{path}/adsmanagement_{locale}.{extension}</rule>
<rule pattern="**/detail_es.properties">{path}/detail_{locale}.{extension}</rule>
<rule pattern="**/info_es.properties">{path}/info_{locale}.{extension}</rule>
<rule pattern="**/alert_es.properties">{path}/alert_{locale}.{extension}</rule>
<rule pattern="**/breadcrumb_es.properties">{path}/breadcrumb_{locale}.{extension}</rule>
<rule pattern="**/einvoice_es.properties">{path}/einvoice_{locale}.{extension}</rule>
<rule pattern="**/agents_es.properties">{path}/agents_{locale}.{extension}</rule>
<rule pattern="**/neighborhoodranking_es.properties">{path}/neighborhoodranking_{locale}.{extension}</rule>
<rule pattern="**/branding_es.properties">{path}/branding_{locale}.{extension}</rule>
<rule pattern="**/microsite_es.properties">{path}/microsite_{locale}.{extension}</rule>
<rule pattern="**/webtool_es.properties">{path}/webtool_{locale}.{extension}</rule>
<rule pattern="**/stats_es.properties">{path}/stats_{locale}.{extension}</rule>
<rule pattern="**/semanticlocations_es.properties">{path}/semanticlocations_{locale}.{extension}</rule>
<rule pattern="**/locations_es.properties">{path}/locations_{locale}.{extension}</rule>
<rule pattern="**/mortgages_es.properties">{path}/mortgages_{locale}.{extension}</rule>
<rule pattern="**/savedads_es.properties">{path}/savedads_{locale}.{extension}</rule>
<rule pattern="**/online-sign_es.properties">{path}/online-sign_{locale}.{extension}</rule>
<rule pattern="**/adsdataacquisition_es.properties">{path}/adsdataacquisition_{locale}.{extension}</rule>
<rule pattern="**/multimedia_es.properties">{path}/multimedia_{locale}.{extension}</rule>
<rule pattern="**/shoppingcart_es.properties">{path}/shoppingcart_{locale}.{extension}</rule>
<rule pattern="**/sharedflats_es.properties">{path}/sharedflats_{locale}.{extension}</rule>
<rule pattern="**/pricepolicy_es.properties">{path}/pricepolicy_{locale}.{extension}</rule>
<rule pattern="**/generic_es.properties">{path}/generic_{locale}.{extension}</rule>
<rule pattern="**/commons_es.properties">{path}/commons_{locale}.{extension}</rule>
<rule pattern="**/errors_es.properties">{path}/errors_{locale}.{extension}</rule>
<rule pattern="**/drawingmode_es.properties">{path}/drawingmode_{locale}.{extension}</rule>
<rule pattern="**/jobs.properties">{path}/jobs_{locale}.{extension}</rule>
<rule pattern="**/idealistadata_es.properties">{path}/idealistadata_{locale}.{extension}</rule>
</rules>
</config>
Former user 4 April 2017 at 01:41
@DanielO Carlos's suggestion should also work. Can you show us your config file?
Former user 4 April 2017 at 00:49
Unfortunately we don't support this usage natively. We consider filename being the file without extension, regardless whether you have locale embedded in it or not. In fact, it's hard to tell whether a portion in filename is actually locale. If you don't want to include 'es' in your translation file name, here is a workaround by using command hooks http://docs.zanata.org/en/release/client/command-hook/:
<src-dir>src/main/resources/conf/i18n/</src-dir>
<trans-dir>src/main/resources/conf/i18n/</trans-dir>
<hooks>
<hook command="push">
<!-- before pushing to Zanata, rename your file to remove the locale and then revert after -->
<before>mv src/main/resources/conf/i18n/sourcefile_es.properties src/main/resources/conf/i18n/sourcefile.properties</before>
<after>mv src/main/resources/conf/i18n/sourcefile.properties src/main/resources/conf/i18n/sourcefile_es.properties</after>
</hook>
<!-- you don't need to do anything for pull since properties file don't require source file to build up translation files (as oppose to gettext project) -->
</hooks>
This should give you a relatively clean configuration. You still need to specify '--src-lang es' (if use zanata-cli) or '<srcLang>es</srcLang>' in pom if use maven. Zanata has bugs in the areas where English is not source language. See ZNTA-1587. I will also link this issue to that one.
Details
Details
Assignee
Reporter
Tested Version/s
Components
Sprint
Fix versions
Affects versions
Priority

Using the maven plugin configured as shown bellow:
<plugin> <groupId>org.zanata</groupId> <artifactId>zanata-maven-plugin</artifactId> <version>4.0.0</version> <configuration> <srcDir>src/main/resources/conf/i18n/</srcDir> <transDir>src/main/resources/conf/i18n/</transDir> <pushType>both</pushType> <logHttp>false</logHttp> <validate>false</validate> <sourceLang>es</sourceLang> </configuration> </plugin>
And using this config file (zanata.xml):
<config xmlns="http://zanata.org/namespace/config/"> <url>http://10.0.0.2:8080/zanata/</url> <project>test</project> <project-version>test</project-version> <project-type>utf8properties</project-type> <src-dir>src/main/resources/conf/i18n</src-dir> <trans-dir>src/main/resources/conf/i18n</trans-dir> <rules> <!-- Generic (not country deployment specific properties): * Locale "es" is always the source * The target is specified in the same path but with locale as suffix --> <rule pattern="**/*_es.properties">{path}/{filename}_{locale}.{extension}</rule> </rules> </config>
My project file structure is like this:
src/main/resources/conf/i18n/sourcefile_es.properties <- example source file
src/main/resources/conf/i18n/exampletargetfile_pt.properties <- example target file
The targets (translations) aren't recognized because the filename always contains the source locale. Using "both" pushType, translations are never uploaded
I think that the problem is in this line https://github.com/zanata/zanata-platform/blob/c8173883718b857ff04249ee7fc843c32a173170/client/zanata-client-commands/src/main/java/org/zanata/client/commands/FileMappingRuleHandler.java#L134 because only removes the extension to build the filename placeholder/variable.