summaryrefslogtreecommitdiff
path: root/svl
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2017-06-11 20:56:30 +0100
committerCaolán McNamara <caolanm@redhat.com>2017-07-21 08:20:50 +0100
commit00657aef09d854c74fb426a935a3e8b1fc390bb0 (patch)
treefd1a9bb264fe15dcc129498e62060ecd256b1ee7 /svl
parentfa987cbb813cfd729fe490f2f1258b7c8d7fb174 (diff)
migrate to boost::gettext
* all .ui files go from <interface> to <interface domain="MODULE"> e.g. vcl * all .src files go away and the english source strings folded into the .hrc as NC_("context", "source string") * ResMgr is dropped in favour of std::locale imbued by boost::locale::generator pointed at matching MODULE .mo files * UIConfig translations are folded into the module .mo, so e.g. UIConfig_cui goes from l10n target to normal one, so the res/lang.zips of UI files go away * translation via Translation::get(hrc-define-key, imbued-std::locale) * python can now be translated with its inbuilt gettext support (we keep the name strings.hrc there to keep finding the .hrc file uniform) so magic numbers can go away there * java and starbasic components can be translated via the pre-existing css.resource.StringResourceWithLocation mechanism * en-US res files go away, their strings are now the .hrc keys in the source code * remaining .res files are replaced by .mo files * in .res/.ui-lang-zip files, the old scheme missing translations of strings results in inserting the english original so something can be found, now the standard fallback of using the english original from the source key is used, so partial translations shrink dramatically in size * extract .hrc strings with hrcex which backs onto xgettext -C --add-comments --keyword=NC_:1c,2 --from-code=UTF-8 --no-wrap * extract .ui strings with uiex which backs onto xgettext --add-comments --no-wrap * qtz for gettext translations is generated at runtime as ascii-ified crc32 of content + "|" + msgid * [API CHANGE] remove deprecated binary .res resouce loader related uno apis com::sun::star::resource::OfficeResourceLoader com::sun::star::resource::XResourceBundleLoader com::sun::star::resource::XResourceBundle when translating strings via uno apis com.sun.star.resource.StringResourceWithLocation can continue to be used Change-Id: Ia2594a2672b7301d9c3421fdf31b6cfe7f3f8d0a
Diffstat (limited to 'svl')
-rw-r--r--svl/AllLangMoTarget_svl.mk11
-rw-r--r--svl/AllLangResTarget_svl.mk32
-rw-r--r--svl/Module_svl.mk2
-rw-r--r--svl/source/misc/getstringresource.cxx24
-rw-r--r--svl/source/misc/getstringresource.hxx3
-rw-r--r--svl/source/misc/inettype.cxx10
-rw-r--r--svl/source/misc/mediatyp.src369
7 files changed, 25 insertions, 426 deletions
diff --git a/svl/AllLangMoTarget_svl.mk b/svl/AllLangMoTarget_svl.mk
new file mode 100644
index 000000000000..8a1b2b7ad90e
--- /dev/null
+++ b/svl/AllLangMoTarget_svl.mk
@@ -0,0 +1,11 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+$(eval $(call gb_AllLangMoTarget_AllLangMoTarget,svl))
+
+# vim: set noet sw=4 ts=4:
diff --git a/svl/AllLangResTarget_svl.mk b/svl/AllLangResTarget_svl.mk
deleted file mode 100644
index 30baf34c6e70..000000000000
--- a/svl/AllLangResTarget_svl.mk
+++ /dev/null
@@ -1,32 +0,0 @@
-# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
-#
-# This file is part of the LibreOffice project.
-#
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-#
-# This file incorporates work covered by the following license notice:
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed
-# with this work for additional information regarding copyright
-# ownership. The ASF licenses this file to you under the Apache
-# License, Version 2.0 (the "License"); you may not use this file
-# except in compliance with the License. You may obtain a copy of
-# the License at http://www.apache.org/licenses/LICENSE-2.0 .
-#
-
-$(eval $(call gb_AllLangResTarget_AllLangResTarget,svl))
-
-$(eval $(call gb_AllLangResTarget_add_srs,svl,\
- svl/res \
-))
-
-$(eval $(call gb_SrsTarget_SrsTarget,svl/res))
-
-$(eval $(call gb_SrsTarget_add_files,svl/res,\
- svl/source/misc/mediatyp.src \
-))
-
-# vim: set noet sw=4 ts=4:
diff --git a/svl/Module_svl.mk b/svl/Module_svl.mk
index 18d79ab3cc85..d14e184b65a9 100644
--- a/svl/Module_svl.mk
+++ b/svl/Module_svl.mk
@@ -26,7 +26,7 @@ $(eval $(call gb_Module_add_targets,svl,\
))
$(eval $(call gb_Module_add_l10n_targets,svl,\
- AllLangResTarget_svl \
+ AllLangMoTarget_svl \
))
$(eval $(call gb_Module_add_check_targets,svl,\
diff --git a/svl/source/misc/getstringresource.cxx b/svl/source/misc/getstringresource.cxx
index fe18e9635c35..98c7d4a26ac4 100644
--- a/svl/source/misc/getstringresource.cxx
+++ b/svl/source/misc/getstringresource.cxx
@@ -27,7 +27,6 @@
#include <rtl/ustring.hxx>
#include <sal/types.h>
#include <tools/resmgr.hxx>
-#include <tools/simplerm.hxx>
#include "getstringresource.hxx"
@@ -36,14 +35,13 @@ namespace {
class ResMgrMap {
public:
ResMgrMap() = default;
- ~ResMgrMap();
ResMgrMap(const ResMgrMap&) = delete;
ResMgrMap& operator=(const ResMgrMap&) = delete;
- SimpleResMgr * get(LanguageTag const & locale);
+ const std::locale& get(LanguageTag const & locale);
private:
- typedef std::map< OUString, SimpleResMgr * > Map;
+ typedef std::map<OUString, std::locale> Map;
Map map_;
// one SimpleResMgr for each language for which a resource was requested
@@ -53,20 +51,12 @@ private:
// for each language ever requested)
};
-ResMgrMap::~ResMgrMap() {
- for (Map::iterator i(map_.begin()); i != map_.end(); ++i) {
- delete i->second;
- }
-}
-
-SimpleResMgr * ResMgrMap::get(LanguageTag const & locale) {
+const std::locale& ResMgrMap::get(LanguageTag const & locale) {
OUString code( locale.getBcp47());
Map::iterator i(map_.find(code));
if (i == map_.end()) {
- std::unique_ptr< SimpleResMgr > mgr(
- new SimpleResMgr("svl", locale));
- i = map_.insert(Map::value_type(code, mgr.get())).first;
- mgr.reset();
+ std::locale loc = Translate::Create("svl", locale);
+ i = map_.insert(Map::value_type(code, loc)).first;
}
return i->second;
}
@@ -77,9 +67,9 @@ struct theResMgrMap: public rtl::Static< ResMgrMap, theResMgrMap > {};
namespace svl {
-OUString getStringResource(sal_uInt16 id, LanguageTag const & locale)
+OUString getStringResource(const char* id, LanguageTag const & locale)
{
- return theResMgrMap::get().get(locale)->ReadString(id);
+ return Translate::get(id, theResMgrMap::get().get(locale));
}
}
diff --git a/svl/source/misc/getstringresource.hxx b/svl/source/misc/getstringresource.hxx
index 3fcde3883f88..4776c1572754 100644
--- a/svl/source/misc/getstringresource.hxx
+++ b/svl/source/misc/getstringresource.hxx
@@ -31,8 +31,7 @@ namespace com { namespace sun { namespace star { namespace lang {
namespace svl {
OUString getStringResource(
- sal_uInt16 id, LanguageTag const & locale);
-
+ const char* id, LanguageTag const & locale);
}
#endif
diff --git a/svl/source/misc/inettype.cxx b/svl/source/misc/inettype.cxx
index b073e8b9b0ba..3da903827455 100644
--- a/svl/source/misc/inettype.cxx
+++ b/svl/source/misc/inettype.cxx
@@ -213,7 +213,7 @@ MediaTypeEntry const aStaticTypeNameMap[CONTENT_TYPE_LAST + 1]
/** A mapping from type IDs to presentation resource IDs. Sorted by type ID.
*/
-sal_uInt16 const aStaticResourceIDMap[CONTENT_TYPE_LAST + 1]
+const char* aStaticResourceIDMap[CONTENT_TYPE_LAST + 1]
= { STR_SVT_MIMETYPE_APP_OCTSTREAM, // CONTENT_TYPE_UNKNOWN
STR_SVT_MIMETYPE_APP_OCTSTREAM, // CONTENT_TYPE_APP_OCTSTREAM
STR_SVT_MIMETYPE_APP_PDF, // CONTENT_TYPE_APP_PDF
@@ -604,18 +604,18 @@ OUString INetContentTypes::GetContentType(INetContentType eTypeID)
OUString INetContentTypes::GetPresentation(INetContentType eTypeID,
const LanguageTag& aLocale)
{
- sal_uInt16 nResID = sal_uInt16();
+ const char* pResID = nullptr;
if (eTypeID <= CONTENT_TYPE_LAST)
- nResID = aStaticResourceIDMap[eTypeID];
+ pResID = aStaticResourceIDMap[eTypeID];
else
{
OUString aPresentation = Registration::GetPresentation(eTypeID);
if (aPresentation.isEmpty())
- nResID = STR_SVT_MIMETYPE_APP_OCTSTREAM;
+ pResID = STR_SVT_MIMETYPE_APP_OCTSTREAM;
else
return aPresentation;
}
- return svl::getStringResource(nResID, aLocale);
+ return svl::getStringResource(pResID, aLocale);
}
//static
diff --git a/svl/source/misc/mediatyp.src b/svl/source/misc/mediatyp.src
deleted file mode 100644
index 2ea4da899369..000000000000
--- a/svl/source/misc/mediatyp.src
+++ /dev/null
@@ -1,369 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-// Internet Media Type Presentations
-
-#include <svl/svl.hrc>
-
-String STR_SVT_MIMETYPE_APP_OCTSTREAM
-{
- Text [ en-US ] = "Binary file" ;
-};
-
-String STR_SVT_MIMETYPE_APP_PDF
-{
- Text [ en-US ] = "PDF file" ;
-};
-
-String STR_SVT_MIMETYPE_APP_RTF
-{
- Text [ en-US ] = "RTF File" ;
-};
-
-String STR_SVT_MIMETYPE_APP_MSWORD
-{
- Text [ en-US ] = "MS-Word document" ;
-};
-
-String STR_SVT_MIMETYPE_APP_STARCALC
-{
- Text [ en-US ] = "%PRODUCTNAME Spreadsheet" ;
-};
-
-String STR_SVT_MIMETYPE_APP_STARCHART
-{
- Text [ en-US ] = "%PRODUCTNAME Chart" ;
-};
-
-String STR_SVT_MIMETYPE_APP_STARDRAW
-{
- Text [ en-US ] = "%PRODUCTNAME Drawing" ;
-};
-
-String STR_SVT_MIMETYPE_APP_STARIMAGE
-{
- Text [ en-US ] = "%PRODUCTNAME Image" ;
-};
-
-String STR_SVT_MIMETYPE_APP_STARMATH
-{
- Text [ en-US ] = "%PRODUCTNAME Formula" ;
-};
-
-String STR_SVT_MIMETYPE_APP_STARWRITER
-{
- Text [ en-US ] = "%PRODUCTNAME Text" ;
-};
-
-String STR_SVT_MIMETYPE_APP_ZIP
-{
- Text [ en-US ] = "ZIP file" ;
-};
-
-String STR_SVT_MIMETYPE_APP_JAR
-{
- Text [ en-US ] = "JAR file" ;
-};
-
-String STR_SVT_MIMETYPE_AUDIO_AIFF
-{
- Text [ en-US ] = "Audio file" ;
-};
-
-String STR_SVT_MIMETYPE_AUDIO_BASIC
-{
- Text [ en-US ] = "Audio file" ;
-};
-
-String STR_SVT_MIMETYPE_AUDIO_MIDI
-{
- Text [ en-US ] = "Audio file" ;
-};
-
-String STR_SVT_MIMETYPE_AUDIO_VORBIS
-{
- Text [ en-US ] = "Audio file" ;
-};
-
-String STR_SVT_MIMETYPE_AUDIO_WAV
-{
- Text [ en-US ] = "Audio file" ;
-};
-
-String STR_SVT_MIMETYPE_AUDIO_WEBM
-{
- Text [ en-US ] = "Audio file" ;
-};
-
-String STR_SVT_MIMETYPE_IMAGE_GIF
-{
- Text [ en-US ] = "Image" ;
-};
-
-String STR_SVT_MIMETYPE_IMAGE_JPEG
-{
- Text [ en-US ] = "Image" ;
-};
-
-String STR_SVT_MIMETYPE_IMAGE_PCX
-{
- Text [ en-US ] = "Image" ;
-};
-
-String STR_SVT_MIMETYPE_IMAGE_BMP
-{
- Text [ en-US ] = "Bitmap" ;
-};
-
-String STR_SVT_MIMETYPE_TEXT_HTML
-{
- Text [ en-US ] = "HTML document" ;
-};
-
-String STR_SVT_MIMETYPE_TEXT_PLAIN
-{
- Text [ en-US ] = "Text file" ;
-};
-
-String STR_SVT_MIMETYPE_TEXT_URL
-{
- Text [ en-US ] = "Bookmark" ;
-};
-
-String STR_SVT_MIMETYPE_TEXT_VCARD
-{
- Text [ en-US ] = "vCard file" ;
-};
-
-String STR_SVT_MIMETYPE_VIDEO_MSVIDEO
-{
- Text [ en-US ] = "Video file" ;
-};
-
-String STR_SVT_MIMETYPE_VIDEO_THEORA
-{
- Text [ en-US ] = "Video file" ;
-};
-
-String STR_SVT_MIMETYPE_VIDEO_VDO
-{
- Text [ en-US ] = "Video file" ;
-};
-
-String STR_SVT_MIMETYPE_VIDEO_WEBM
-{
- Text [ en-US ] = "Video file" ;
-};
-
-String STR_SVT_MIMETYPE_X_STARMAIL
-{
- Text [ en-US ] = "Message" ;
-};
-
-String STR_SVT_MIMETYPE_X_VRML
-{
- Text [ en-US ] = "VRML file" ;
-};
-
-String STR_SVT_MIMETYPE_APP_STARIMPRESS
-{
- Text [ en-US ] = "%PRODUCTNAME Presentation" ;
-};
-
-String STR_SVT_MIMETYPE_APP_IMPRESSPACKED
-{
- Text [ en-US ] = "%PRODUCTNAME Presentation (packed)";
-};
-
-String STR_SVT_MIMETYPE_APP_STARHELP
-{
- Text [ en-US ] = "%PRODUCTNAME Help" ;
-};
-
-String STR_SVT_MIMETYPE_CNT_FSYSBOX
-{
- Text [ en-US ] = "Workplace" ;
-};
-
-String STR_SVT_MIMETYPE_CNT_FSYSFLD
-{
- Text [ en-US ] = "Folder" ;
-};
-
-String STR_SVT_MIMETYPE_APP_GAL
-{
- Text [ en-US ] = "Gallery";
-};
-
-String STR_SVT_MIMETYPE_APP_GAL_THEME
-{
- Text [ en-US ] = "Gallery theme" ;
-};
-
-String STR_SVT_MIMETYPE_APP_STARW_GLOB
-{
- Text [ en-US ] = "%PRODUCTNAME Master Document" ;
-};
-
-String STR_SVT_MIMETYPE_APP_SDM
-{
- Text [ en-US ] = "Message" ;
-};
-
-String STR_SVT_MIMETYPE_APP_SMD
-{
- Text [ en-US ] = "Message" ;
-};
-
-String STR_SVT_MIMETYPE_APP_STARW_WEB
-{
- Text [ en-US ] = "%PRODUCTNAME Writer/Web" ;
-};
-
-String STR_SVT_MIMETYPE_FRAMESET
-{
- Text [ en-US ] = "Frameset Document" ;
-};
-
-String STR_SVT_MIMETYPE_MACRO
-{
- Text [ en-US ] = "Macro file" ;
-};
-
-String STR_SVT_MIMETYPE_CNT_SFSYSFOLDER
-{
- Text [ en-US ] = "System folder" ;
-};
-
-String STR_SVT_MIMETYPE_APP_TEMPLATE
-{
- Text [ en-US ] = "%PRODUCTNAME Template";
-};
-
-String STR_SVT_MIMETYPE_IMAGE_GENERIC
-{
- Text [ en-US ] = "Image";
-};
-
-String STR_SVT_MIMETYPE_APP_MSEXCEL
-{
- Text [ en-US ] = "MS Excel document" ;
-};
-
-String STR_SVT_MIMETYPE_APP_MSEXCEL_TEMPL
-{
- Text [ en-US ] = "MS Excel Template" ;
-};
-
-String STR_SVT_MIMETYPE_APP_MSPPOINT
-{
- Text [ en-US ] = "MS PowerPoint document" ;
-};
-
-String STR_SVT_MIMETYPE_TEXT_VCALENDAR
-{
- Text [ en-US ] = "vCalendar-file" ;
-};
-
-String STR_SVT_MIMETYPE_TEXT_ICALENDAR
-{
- Text [ en-US ] = "iCalendar-File";
-};
-
-String STR_SVT_MIMETYPE_TEXT_XMLICALENDAR
-{
- Text [ en-US ] = "XML-iCalendar-File";
-};
-
-String STR_SVT_MIMETYPE_TEXT_CDE_CALENDAR_APP
-{
- Text [ en-US ] = "CDE-Calendar-File";
-};
-
-String STR_SVT_MIMETYPE_INET_MSG_RFC822
-{
- Text [ en-US ] = "message/rfc822" ;
-};
-
-String STR_SVT_MIMETYPE_INET_MULTI_ALTERNATIVE
-{
- Text [ en-US ] = "multipart/alternative" ;
-};
-
-String STR_SVT_MIMETYPE_INET_MULTI_DIGEST
-{
- Text [ en-US ] = "multipart/digest" ;
-};
-
-String STR_SVT_MIMETYPE_INET_MULTI_PARALLEL
-{
- Text [ en-US ] = "multipart/parallel" ;
-};
-
-String STR_SVT_MIMETYPE_INET_MULTI_RELATED
-{
- Text [ en-US ] = "multipart/related" ;
-};
-
-String STR_SVT_MIMETYPE_INET_MULTI_MIXED
-{
- Text [ en-US ] = "multipart/mixed" ;
-};
-
-String STR_SVT_MIMETYPE_APP_SXCALC
-{
- Text [ en-US ] = "OpenOffice.org 1.0 Spreadsheet" ;
-};
-
-String STR_SVT_MIMETYPE_APP_SXCHART
-{
- Text [ en-US ] = "OpenOffice.org 1.0 Chart" ;
-};
-
-String STR_SVT_MIMETYPE_APP_SXDRAW
-{
- Text [ en-US ] = "OpenOffice.org 1.0 Drawing" ;
-};
-
-String STR_SVT_MIMETYPE_APP_SXMATH
-{
- Text [ en-US ] = "OpenOffice.org 1.0 Formula" ;
-};
-
-String STR_SVT_MIMETYPE_APP_SXWRITER
-{
- Text [ en-US ] = "OpenOffice.org 1.0 Text Document" ;
-};
-
-String STR_SVT_MIMETYPE_APP_SXIMPRESS
-{
- Text [ en-US ] = "OpenOffice.org 1.0 Presentation" ;
-};
-
-String STR_SVT_MIMETYPE_APP_SXGLOBAL
-{
- Text [ en-US ] = "OpenOffice.org 1.0 Master Document" ;
-};
-
-String STR_SVT_MIMETYPE_APP_SXIPACKED
-{
- Text [ en-US ] = "OpenOffice.org 1.0 Presentation (packed)" ;
-};
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */