Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
core
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
LibreOffice
core
Commits
c2866a9d
Kaydet (Commit)
c2866a9d
authored
Ock 20, 2014
tarafından
Caolán McNamara
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Related: #i56998# provide a way to format % per-locale rules
Change-Id: Ic27b230cc9dce366f281ff720ded5873e94f6191
üst
daaa6425
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
36 additions
and
0 deletions
+36
-0
Library_i18nutil.mk
i18nutil/Library_i18nutil.mk
+3
-0
unicode.cxx
i18nutil/source/utility/unicode.cxx
+26
-0
unicode.hxx
include/i18nutil/unicode.hxx
+7
-0
No files found.
i18nutil/Library_i18nutil.mk
Dosyayı görüntüle @
c2866a9d
...
...
@@ -21,6 +21,8 @@ $(eval $(call gb_Library_Library,i18nutil))
$(eval $(call gb_Library_use_externals,i18nutil,\
boost_headers \
icu_headers \
icui18n \
icuuc \
))
$(eval $(call gb_Library_use_custom_headers,i18nutil,\
...
...
@@ -34,6 +36,7 @@ $(eval $(call gb_Library_add_defs,i18nutil,\
))
$(eval $(call gb_Library_use_libraries,i18nutil,\
i18nlangtag \
comphelper \
cppu \
sal \
...
...
i18nutil/source/utility/unicode.cxx
Dosyayı görüntüle @
c2866a9d
...
...
@@ -17,10 +17,14 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include <boost/scoped_ptr.hpp>
#include <com/sun/star/i18n/UnicodeType.hpp>
#include <com/sun/star/i18n/KCharacterType.hpp>
#include <com/sun/star/i18n/ScriptType.hpp>
#include <i18nlangtag/languagetag.hxx>
#include <i18nlangtag/languagetagicu.hxx>
#include <i18nutil/unicode.hxx>
#include <unicode/numfmt.h>
#include "unicode_data.h"
// Workaround for glibc braindamage:
...
...
@@ -934,4 +938,26 @@ OString SAL_CALL unicode::getExemplarLanguageForUScriptCode(UScriptCode eScript)
return
sRet
;
}
//Format a number as a percentage according to the rules of the given
//language, e.g. 100 -> "100%" for en-US vs "100 %" for de-DE
OUString
SAL_CALL
unicode
::
formatPercent
(
double
dNumber
,
const
LanguageTag
&
rLangTag
)
{
// get a currency formatter for this locale ID
UErrorCode
errorCode
=
U_ZERO_ERROR
;
icu
::
Locale
aLocale
=
LanguageTagIcu
::
getIcuLocale
(
rLangTag
);
boost
::
scoped_ptr
<
NumberFormat
>
xF
(
NumberFormat
::
createPercentInstance
(
aLocale
,
errorCode
));
if
(
U_FAILURE
(
errorCode
))
{
SAL_WARN
(
"i18n"
,
"NumberFormat::createPercentInstance failed"
);
return
OUString
::
number
(
dNumber
)
+
"%"
;
}
UnicodeString
output
;
xF
->
format
(
dNumber
,
output
);
return
OUString
(
reinterpret_cast
<
const
sal_Unicode
*>
(
output
.
getBuffer
()),
output
.
length
());
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
include/i18nutil/unicode.hxx
Dosyayı görüntüle @
c2866a9d
...
...
@@ -24,6 +24,8 @@
#include <unicode/uscript.h>
#include <i18nutil/i18nutildllapi.h>
class
LanguageTag
;
typedef
struct
_ScriptTypeList
{
sal_Int16
from
;
sal_Int16
to
;
...
...
@@ -54,6 +56,11 @@ public:
//Return a language that can be written in a given ISO 15924 script code
static
OString
SAL_CALL
getExemplarLanguageForUScriptCode
(
UScriptCode
eScript
);
//Format a number as a percentage according to the rules of the given
//language, e.g. 100 -> "100%" for en-US vs "100 %" for de-DE
static
OUString
SAL_CALL
formatPercent
(
double
dNumber
,
const
LanguageTag
&
rLangTag
);
};
#endif
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment