There is source code comment that is TODO to request documention in o.o.CLIParameters.java
// TODO: Document this; see RealProject.patchFileNameForEntryKey()
public static final String ALTERNATE_FILENAME_FROM = "alternate-filename-from";
// TODO: Document this; see RealProject.patchFileNameForEntryKey()
public static final String ALTERNATE_FILENAME_TO = "alternate-filename-to";
TODO guide doucment writr to see RealProject.patchFileNameForEntryKey()
/**
* This method converts directory separators into Unix-style. It required to
* have the same filenames in the alternative translation in Windows and
* Unix boxes.
* <p>
* Also it can use {@code --alternate-filename-from} and
* {@code --alternate-filename-to} command line parameters for change
* filename in entry key. It allows to have many versions of one file in one
* project.
* <p>
* Because the filename can be stored in the project TMX, it also removes
* any XML-unsafe chars.
*
* @param filename
* filesystem's filename
* @return normalized filename
*/
protected String patchFileNameForEntryKey(String filename) {
String f = Core.getParams().get(CLIParameters.ALTERNATE_FILENAME_FROM);
String t = Core.getParams().get(CLIParameters.ALTERNATE_FILENAME_TO);
String fn = filename.replace('\\', '/');
if (f != null && t != null) {
fn = fn.replaceAll(f, t);
}
return StringUtil.removeXMLInvalidChars(fn);
}
Hiroshi, I don’t understand the description of the parameters.
What kind of (string) value do the parameters expect?
This feature was written by Alex Buloichik in 2011.
He left a commit message "Support multiple source file versions in one project".
The feature use --alternate-filename-from and --alternate-filename-to command line parameters for change filename in entry key. It allows to have many versions of one file in one project.
Could you give a practical exemple ? I’m not sure I understand that description.
No, there is no sample because the feature does not have both unit test and functional test, so there is no written expectation other than comment and code in the source code in the project.
I can explain terms in the comment;
SourceTextEntry
which hold a segment text distilled fromsource/
files. The EntryKey class keepfile
sourceText
id
prev
next
path
as its fields. OmegaT usesentryKey key
as a key of the translation memory.file
field text value from value to to value. The value offile
hold a filename of source file undersource/
folder.I do not know what feature Alex try to implement, I cannot explain what is the feature.
From a behavior of the feature, when there is a project TMX translation entry for the file
version-1.txt
, and you are translatingsource/version-2.txt
then you specify change file nameversion2.txt
toversion-1.txt
, the same source text inversion-2.txt
should match exact with the translation memory forversion-1.txt
with the same entry key as 100%.Diff: