1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef INCLUDED_L10NTOOLS_INC_EXPORT_HXX
21 #define INCLUDED_L10NTOOLS_INC_EXPORT_HXX
23 #include <sal/config.h>
29 #include <osl/file.hxx>
34 #include <unordered_map>
39 #include <string_view>
47 #define NO_TRANSLATE_ISO "x-no-translate"
51 typedef std::unordered_map
<OString
, OString
>
54 typedef std::unordered_map
<OString
, bool>
57 #define SOURCE_LANGUAGE "en-US"
58 #define X_COMMENT "x-comment"
63 /// Purpose: holds mandatory data to export a single res
67 ResData( const OString
&rGId
);
68 ResData( const OString
&rGId
, const OString
&rFilename
);
85 /// Purpose: holds information of data to merge
88 friend class MergeDataFile
;
91 OStringBoolHashMap bTextFirst
;
92 OStringHashMap sQuickHelpText
;
93 OStringBoolHashMap bQuickHelpTextFirst
;
94 OStringHashMap sTitle
;
95 OStringBoolHashMap bTitleFirst
;
99 void InsertEntry(const OString
&rId
, const OString
&rText
,
100 const OString
&rQuickHelpText
, const OString
&rTitle
)
103 sText
[ rId
] = rText
;
104 bTextFirst
[ rId
] = true;
105 sQuickHelpText
[ rId
] = rQuickHelpText
;
106 bQuickHelpTextFirst
[ rId
] = true;
107 sTitle
[ rId
] = rTitle
;
108 bTitleFirst
[ rId
] = true;
110 bool GetText( OString
&rReturn
, const OString
&nLangIndex
, bool bDel
= false );
113 Generate QTZ string with ResData
114 For executable which works one language and without PO files.
116 static OString
GetQTZText(const ResData
& rResData
, std::string_view rOrigText
);
122 /// Purpose: holds information of data to merge, read from PO file
126 std::unordered_map
<OString
, std::unique_ptr
<MergeEntrys
>> aMap
;
127 std::set
<OString
> aLanguageSet
;
129 MergeEntrys
*GetMergeData( ResData
*pResData
, bool bCaseSensitive
= false );
130 void InsertEntry(std::string_view rTYP
, std::string_view rGID
,
131 std::string_view rLID
, const OString
&nLang
,
132 const OString
&rTEXT
, const OString
&rQHTEXT
,
133 const OString
&rTITLE
, const OString
&sFilename
,
134 bool bFirstLang
, bool bCaseSensitive
);
136 explicit MergeDataFile(
137 const OString
&rFileName
, const OString
& rFile
,
138 bool bCaseSensitive
, bool bWithQtz
= true );
142 std::vector
<OString
> GetLanguages() const;
144 MergeEntrys
*GetMergeEntrys( ResData
*pResData
);
145 MergeEntrys
*GetMergeEntrysCaseSensitive( ResData
*pResData
);
147 static OString
CreateKey(std::string_view rTYP
, std::string_view rGID
,
148 std::string_view rLID
, const OString
& rFilename
, bool bCaseSensitive
);
152 #endif // INCLUDED_L10NTOOLS_INC_EXPORT_HXX
154 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */