Menu

#427 CLI parameter documentation

open
None
6
2025-02-09
2024-11-07
No

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);
    }

Discussion

  • Jean-Christophe Helary

    • assigned_to: Jean-Christophe Helary
     
  • Jean-Christophe Helary

    Hiroshi, I don’t understand the description of the parameters.

    What kind of (string) value do the parameters expect?

     
    • Hiroshi Miura

      Hiroshi Miura - 2025-01-23

      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.

       
      • Jean-Christophe Helary

        Could you give a practical exemple ? I’m not sure I understand that description.

         
        • Hiroshi Miura

          Hiroshi Miura - 2025-01-23

          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;

          • entry key is a field of the very basic OmegaT object SourceTextEntry which hold a segment text distilled from source/ files. The EntryKey class keep file sourceText id prev next path as its fields. OmegaT uses entryKey key as a key of the translation memory.
          • "change filename in entry key" means that it replace file field text value from value to to value. The value of file hold a filename of source file under source/ 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 translating source/version-2.txt then you specify change file name version2.txt to version-1.txt, the same source text in version-2.txt should match exact with the translation memory for version-1.txt with the same entry key as 100%.

           
  • Hiroshi Miura

    Hiroshi Miura - 2025-01-23
    • Description has changed:

    Diff:

    --- old
    +++ new
    @@ -1,4 +1,4 @@
    -There is TODO to request documention in o.o.CLIParameters.java 
    +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 = &#34;alternate-filename-from&#34;;
    @@ -7,7 +7,7 @@
    
     ~~~
    
    -TODO guide doucment wrietr to see `RealProject.patchFileNameForEntryKey()`
    +TODO guide doucment writr to see `RealProject.patchFileNameForEntryKey()`
    
     ~~~
    
     
  • Jean-Christophe Helary

    • Priority: 5 --> 6
     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.