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>
25 #include <rtl/string.hxx>
28 #include <unordered_map>
31 #include <string_view>
37 #define NO_TRANSLATE_ISO "x-no-translate"
41 typedef std::unordered_map
<OString
, OString
>
44 typedef std::unordered_map
<OString
, bool>
47 #define SOURCE_LANGUAGE "en-US"
48 #define X_COMMENT "x-comment"
53 /// Purpose: holds mandatory data to export a single res
57 ResData( OString rGId
);
58 ResData( OString sGId
, OString sFilename
);
75 /// Purpose: holds information of data to merge
78 friend class MergeDataFile
;
81 OStringBoolHashMap bTextFirst
;
82 OStringHashMap sQuickHelpText
;
83 OStringBoolHashMap bQuickHelpTextFirst
;
84 OStringHashMap sTitle
;
85 OStringBoolHashMap bTitleFirst
;
89 void InsertEntry(const OString
&rId
, const OString
&rText
,
90 const OString
&rQuickHelpText
, const OString
&rTitle
)
94 bTextFirst
[ rId
] = true;
95 sQuickHelpText
[ rId
] = rQuickHelpText
;
96 bQuickHelpTextFirst
[ rId
] = true;
97 sTitle
[ rId
] = rTitle
;
98 bTitleFirst
[ rId
] = true;
100 bool GetText( OString
&rReturn
, const OString
&nLangIndex
, bool bDel
= false );
103 Generate QTZ string with ResData
104 For executable which works one language and without PO files.
106 static OString
GetQTZText(const ResData
& rResData
, std::string_view rOrigText
);
112 /// Purpose: holds information of data to merge, read from PO file
116 std::unordered_map
<OString
, std::unique_ptr
<MergeEntrys
>> aMap
;
117 std::set
<OString
> aLanguageSet
;
119 MergeEntrys
*GetMergeData( ResData
*pResData
, bool bCaseSensitive
= false );
120 void InsertEntry(std::string_view rTYP
, std::string_view rGID
,
121 std::string_view rLID
, const OString
&nLang
,
122 const OString
&rTEXT
, const OString
&rQHTEXT
,
123 const OString
&rTITLE
, std::string_view sFilename
,
124 bool bFirstLang
, bool bCaseSensitive
);
126 explicit MergeDataFile(
127 const OString
&rFileName
, std::string_view rFile
,
128 bool bCaseSensitive
, bool bWithQtz
= true );
132 std::vector
<OString
> GetLanguages() const;
134 MergeEntrys
*GetMergeEntrys( ResData
*pResData
);
135 MergeEntrys
*GetMergeEntrysCaseSensitive( ResData
*pResData
);
137 static OString
CreateKey(std::string_view rTYP
, std::string_view rGID
,
138 std::string_view rLID
, std::string_view rFilename
, bool bCaseSensitive
);
142 #endif // INCLUDED_L10NTOOLS_INC_EXPORT_HXX
144 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */