[Libreoffice-commits] core.git: Branch 'libreoffice-6-1' - l10ntools/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Wed Nov 21 12:41:24 UTC 2018


 l10ntools/source/localize.cxx |   55 ++++++++++++++++--------------------------
 1 file changed, 21 insertions(+), 34 deletions(-)

New commits:
commit b29fdf7611d7637886d8d0c50edf5544b928e635
Author:     Christian Lohmaier <lohmaier+LibreOffice at googlemail.com>
AuthorDate: Mon Nov 12 13:09:23 2018 +0100
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Wed Nov 21 13:40:56 2018 +0100

    localize: sort directories to have predictable sorting in pot files
    
    also remove pre-onegit special handling
    
    Change-Id: Ie60be508a188e00b9eea1b743ea10f1f985c459e
    Reviewed-on: https://gerrit.libreoffice.org/63288
    Tested-by: Jenkins
    Reviewed-by: Christian Lohmaier <lohmaier+LibreOffice at googlemail.com>
    (cherry picked from commit 344773c608ea28718b630590ee1023247aa62d63)
    Reviewed-on: https://gerrit.libreoffice.org/63602
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/l10ntools/source/localize.cxx b/l10ntools/source/localize.cxx
index 98098b775456..d36b4f7f6e78 100644
--- a/l10ntools/source/localize.cxx
+++ b/l10ntools/source/localize.cxx
@@ -23,6 +23,7 @@
 #include <cstdlib>
 #include <iostream>
 #include <string>
+#include <map>
 #include <vector>
 #include <algorithm>
 
@@ -317,10 +318,9 @@ bool includeProject(const OString& rProject) {
 ///
 /// @param rUrl the absolute file URL of this directory
 ///
-/// @param nLevel 0 if this is either the root directory that contains the
-/// projects or one of the clone/* or src/* directories that contain the
-/// additional projects; -1 if this is the clone directory; 1 if this
-/// is a project directory; 2 if this is a directory inside a project
+/// @param nLevel 0 if this is the root directory (core repository)
+/// that contains the individual modules. 1 if it is a toplevel module and
+/// larger values for the subdirectories.
 ///
 /// @param rProject the name of the project (empty and ignored if nLevel <= 0)
 /// @param rPotDir the path of pot directory
@@ -335,6 +335,7 @@ void handleDirectory(
         throw false; //TODO
     }
     std::vector<OUString> aFileNames;
+    std::map<OUString, std::map<OString, OString>> aSubDirs;
     for (;;) {
         osl::DirectoryItem item;
         osl::FileBase::RC e = dir.getNextItem(item);
@@ -354,36 +355,18 @@ void handleDirectory(
         }
         const OString sDirName =
             OUStringToOString(stat.getFileName(),RTL_TEXTENCODING_UTF8);
-        switch (nLevel) {
-        case -1: // the clone or src directory
-            if (stat.getFileType() == osl::FileStatus::Directory) {
-                handleDirectory(
-                    stat.getFileURL(), 0, OString(), rPotDir);
-            }
-            break;
-        case 0: // a root directory
-            if (stat.getFileType() == osl::FileStatus::Directory) {
-                if (includeProject(sDirName)) {
-                    handleDirectory(
-                        stat.getFileURL(), 1, sDirName, rPotDir.concat("/").concat(sDirName));
-                } else if ( sDirName == "clone" ||
-                            sDirName == "src" )
-                {
-                    handleDirectory( stat.getFileURL(), -1, OString(), rPotDir);
-                }
-            }
-            break;
-        default:
-            if (stat.getFileType() == osl::FileStatus::Directory)
-            {
-                handleDirectory(
-                    stat.getFileURL(), 2, rProject, rPotDir.concat("/").concat(sDirName));
-            }
-            else
-            {
-                aFileNames.push_back(stat.getFileURL());
-            }
-            break;
+        switch (nLevel)
+        {
+            case 0: // a root directory
+                if (stat.getFileType() == osl::FileStatus::Directory && includeProject(sDirName))
+                    aSubDirs[stat.getFileURL()][sDirName] = rPotDir.concat("/").concat(sDirName);
+                break;
+            default:
+                if (stat.getFileType() == osl::FileStatus::Directory)
+                    aSubDirs[stat.getFileURL()][rProject] = rPotDir.concat("/").concat(sDirName);
+                else
+                    aFileNames.push_back(stat.getFileURL());
+                break;
         }
     }
 
@@ -407,6 +390,10 @@ void handleDirectory(
         throw false; //TODO
     }
 
+    for (auto const& elem : aSubDirs)
+        handleDirectory(elem.first, nLevel + 1, elem.second.begin()->first,
+                        elem.second.begin()->second);
+
     //Remove empty pot directory
     OUString sPoPath =
         OStringToOUString(


More information about the Libreoffice-commits mailing list