Allow srcDir and transDir to overlap safely in FILE projects


The CLI help for zanata-cli push currently includes this statement: "If 'file' is used, transDir must not be the same as or nested within srcDir, and vice versa.". If the 'file' type is to be used for all projects, we will need to remove this limitation.

When pulling translated files in a FILE project, by default they are saved as {locale}/{basename}.{ext}.

The warning is because of this: When pushing source files, the FILE project looks for any files with the expected extension(s), which means that translations in the same directory tree may be picked up and erroneously treated as source files. So a French translation of the source file README.txt might be interpreted as another source file named "fr/README.txt", when in fact it should be ignored.

So a simplistic solution (to allow overlapping srcDir and transDir) would be to skip over any directories which match configured locales, but this may not work if file mapping rules are in use.

A more general solution would be to discard any candidate source file which has the same filename as another candidate after mapping rules have been applied (for all configured locales).

The above approach could be somewhat expensive for large projects, so we should output a message when the number of files times the number of locales is large, and output a recommendation that srcDir and transDir should not overlap.

NB: if srcDir and transDir don't overlap, there is no need to check the candidates against mapping rules, so we shouldn't.





Sean Flanigan



Tested Version/s


Epic Link