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
ef291d99
Kaydet (Commit)
ef291d99
authored
Nis 03, 2013
tarafından
Eike Rathke
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
rsc with language tags
Change-Id: I5401a9bcbd1e359ef62e8d667edf6ead1479ce46
üst
8d470713
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
50 additions
and
92 deletions
+50
-92
rscdb.cxx
rsc/source/parser/rscdb.cxx
+23
-56
rscibas.cxx
rsc/source/parser/rscibas.cxx
+27
-36
No files found.
rsc/source/parser/rscdb.cxx
Dosyayı görüntüle @
ef291d99
...
@@ -23,6 +23,7 @@
...
@@ -23,6 +23,7 @@
#include <string.h>
#include <string.h>
#include <tools/rc.h>
#include <tools/rc.h>
#include <i18npool/languagetag.hxx>
#include <rtl/strbuf.hxx>
#include <rtl/strbuf.hxx>
#include <sal/log.hxx>
#include <sal/log.hxx>
#include <sal/macros.h>
#include <sal/macros.h>
...
@@ -74,76 +75,42 @@ RscTypCont :: RscTypCont( RscError * pErrHdl,
...
@@ -74,76 +75,42 @@ RscTypCont :: RscTypCont( RscError * pErrHdl,
Init
();
Init
();
}
}
static
sal_uInt32
getLangIdAndShortenLocale
(
RscTypCont
*
pTypCont
,
rtl
::
OString
&
rLang
,
rtl
::
OString
&
rCountry
,
rtl
::
OString
&
rVariant
)
{
rtl
::
OStringBuffer
aLangStr
(
64
);
aLangStr
.
append
(
rLang
.
toAsciiLowerCase
()
);
if
(
!
rCountry
.
isEmpty
()
)
{
aLangStr
.
append
(
'-'
);
aLangStr
.
append
(
rCountry
.
toAsciiUpperCase
()
);
}
if
(
!
rVariant
.
isEmpty
()
)
{
aLangStr
.
append
(
'-'
);
aLangStr
.
append
(
rVariant
);
}
rtl
::
OString
aL
(
aLangStr
.
makeStringAndClear
()
);
sal_uInt32
nRet
=
GetLangId
(
aL
);
if
(
nRet
==
0
)
{
pTypCont
->
AddLanguage
(
aL
.
getStr
()
);
nRet
=
GetLangId
(
aL
);
}
if
(
!
rVariant
.
isEmpty
()
)
rVariant
=
rtl
::
OString
();
else
if
(
!
rCountry
.
isEmpty
()
)
rCountry
=
rtl
::
OString
();
else
rLang
=
rtl
::
OString
();
#if OSL_DEBUG_LEVEL > 1
fprintf
(
stderr
,
" %s (0x%hx)"
,
aL
.
getStr
(),
(
int
)
nRet
);
#endif
return
nRet
;
}
rtl
::
OString
RscTypCont
::
ChangeLanguage
(
const
rtl
::
OString
&
rNewLang
)
rtl
::
OString
RscTypCont
::
ChangeLanguage
(
const
rtl
::
OString
&
rNewLang
)
{
{
rtl
::
OString
aRet
=
aLanguage
;
rtl
::
OString
aRet
=
aLanguage
;
aLanguage
=
rNewLang
;
aLanguage
=
rNewLang
;
rtl
::
OString
aLang
=
aLanguage
;
::
std
::
vector
<
OUString
>
aFallbacks
;
rtl
::
OString
aLg
,
aCountry
,
aVariant
;
if
(
rNewLang
.
isEmpty
())
sal_Int32
nIndex
=
0
;
aFallbacks
.
push_back
(
""
);
// do not resolve to SYSTEM (en-US)
aLg
=
aLang
.
getToken
(
0
,
'-'
,
nIndex
);
else
if
(
nIndex
!=
-
1
)
aFallbacks
=
LanguageTag
(
OStringToOUString
(
rNewLang
,
RTL_TEXTENCODING_ASCII_US
)).
getFallbackStrings
();
aCountry
=
aLang
.
getToken
(
0
,
'-'
,
nIndex
);
if
(
nIndex
!=
-
1
)
aVariant
=
aLang
.
copy
(
nIndex
);
bool
bAppendEnUsFallback
=
bool
bAppendEnUsFallback
=
!
(
rNewLang
.
equalsIgnoreAsciiCase
(
"en-US"
)
||
!
(
rNewLang
.
equalsIgnoreAsciiCase
(
"en-US"
)
||
rNewLang
.
equalsIgnoreAsciiCase
(
"x-no-translate"
)
);
rNewLang
.
equalsIgnoreAsciiCase
(
"x-no-translate"
)
);
if
(
bAppendEnUsFallback
)
aFallbacks
.
push_back
(
"en-US"
);
#if OSL_DEBUG_LEVEL > 1
#if OSL_DEBUG_LEVEL > 1
fprintf
(
stderr
,
"RscTypCont::ChangeLanguage:"
);
fprintf
(
stderr
,
"RscTypCont::ChangeLanguage:
"
);
#endif
#endif
aLangFallbacks
.
clear
();
do
aLangFallbacks
.
clear
();
{
aLangFallbacks
.
push_back
(
getLangIdAndShortenLocale
(
this
,
aLg
,
aCountry
,
aVariant
)
);
}
while
(
!
aLg
.
isEmpty
()
);
if
(
bAppendEnUsFallback
)
for
(
::
std
::
vector
<
OUString
>::
const_iterator
it
(
aFallbacks
.
begin
());
it
!=
aFallbacks
.
end
();
++
it
)
{
{
aLg
=
"en"
;
rtl
::
OString
aLang
(
OUStringToOString
(
*
it
,
RTL_TEXTENCODING_ASCII_US
));
aCountry
=
"US"
;
sal_uInt32
nID
=
GetLangId
(
aLang
);
aVariant
=
rtl
::
OString
();
bool
bAdd
=
(
nID
==
0
);
aLangFallbacks
.
push_back
(
getLangIdAndShortenLocale
(
this
,
aLg
,
aCountry
,
aVariant
)
);
if
(
bAdd
)
{
AddLanguage
(
aLang
.
getStr
()
);
nID
=
GetLangId
(
aLang
);
}
#if OSL_DEBUG_LEVEL > 1
fprintf
(
stderr
,
" '%s' (0x%hx) (%s)"
,
aLang
.
getStr
(),
(
int
)
nID
,
(
bAdd
?
"added"
:
"exists"
)
);
#endif
aLangFallbacks
.
push_back
(
nID
);
}
}
#if OSL_DEBUG_LEVEL > 1
#if OSL_DEBUG_LEVEL > 1
...
...
rsc/source/parser/rscibas.cxx
Dosyayı görüntüle @
ef291d99
...
@@ -84,48 +84,35 @@ void RscLangEnum::Init( RscNameTable& rNames )
...
@@ -84,48 +84,35 @@ void RscLangEnum::Init( RscNameTable& rNames )
{
{
#if OSL_DEBUG_LEVEL > 2
#if OSL_DEBUG_LEVEL > 2
fprintf
(
stderr
,
"ISO Language in : %d, 0x%04x, %s
\n
"
,
fprintf
(
stderr
,
"ISO Language in : %d, 0x%04x, %s
\n
"
,
(
int
)
nIndex
,
(
int
)
nIndex
,
(
unsigned
)
pLangEntry
->
mnLang
,
(
unsigned
)
pLangEntry
->
mnLang
,
OUStringToOString
(
LanguageTag
(
pLangEntry
->
mnLang
).
getBcp47
(),
RTL_TEXTENCODING_ASCII_US
).
getStr
()
);
OUStringToOString
(
pLangEntry
->
getTagString
(),
RTL_TEXTENCODING_ASCII_US
).
getStr
());
fprintf
(
stderr
,
"ISO Language out:"
);
#endif
#endif
rtl
::
OString
aLang
(
pLangEntry
->
maLangStr
,
strlen
(
pLangEntry
->
maLangStr
));
LanguageTag
aLanguageTag
(
pLangEntry
->
getTagString
(
));
rtl
::
OString
aCountry
(
pLangEntry
->
maCountry
,
strlen
(
pLangEntry
->
maCountry
));
::
std
::
vector
<
OUString
>
aFallbacks
(
aLanguageTag
.
getFallbackStrings
(
));
if
(
aCountry
.
isEmpty
()
||
aLang
.
equalsIgnoreAsciiCase
(
aCountry
)
)
for
(
::
std
::
vector
<
OUString
>::
const_iterator
it
(
aFallbacks
.
begin
());
it
!=
aFallbacks
.
end
();
++
it
)
{
{
OString
aLang
(
OUStringToOString
(
*
it
,
RTL_TEXTENCODING_ASCII_US
));
SetConstant
(
rNames
.
Put
(
aLang
.
getStr
(),
CONSTNAME
,
mnLangId
),
mnLangId
);
SetConstant
(
rNames
.
Put
(
aLang
.
getStr
(),
CONSTNAME
,
mnLangId
),
mnLangId
);
if
(
!
GetLangId
(
aLang
))
bool
bAdd
=
(
GetLangId
(
aLang
)
==
0
);
if
(
bAdd
)
ULong_Iso_map
[
aLang
]
=
mnLangId
;
ULong_Iso_map
[
aLang
]
=
mnLangId
;
#if OSL_DEBUG_LEVEL > 2
#if OSL_DEBUG_LEVEL > 2
fprintf
(
stderr
,
"
ISO Language out: %s 0x%lx
\n
"
,
aLang
.
getStr
(),
mnLangId
);
fprintf
(
stderr
,
"
%s 0x%lx (%s)"
,
aLang
.
getStr
(),
mnLangId
,
(
bAdd
?
"added"
:
"exists"
)
);
#endif
#endif
mnLangId
++
;
mnLangId
++
;
}
}
else
{
SetConstant
(
rNames
.
Put
(
aLang
.
getStr
(),
CONSTNAME
,
mnLangId
),
mnLangId
);
if
(
!
GetLangId
(
aLang
))
ULong_Iso_map
[
aLang
]
=
mnLangId
;
#if OSL_DEBUG_LEVEL > 2
fprintf
(
stderr
,
"ISO Language out: %s 0x%lx"
,
aLang
.
getStr
(),
mnLangId
);
#endif
mnLangId
++
;
aLang
=
aLang
+
rtl
::
OString
(
'-'
)
+
aCountry
.
toAsciiUpperCase
();
SetConstant
(
rNames
.
Put
(
aLang
.
getStr
(),
CONSTNAME
,
mnLangId
),
mnLangId
);
if
(
!
GetLangId
(
aLang
))
ULong_Iso_map
[
aLang
]
=
mnLangId
;
#if OSL_DEBUG_LEVEL > 2
#if OSL_DEBUG_LEVEL > 2
fprintf
(
stderr
,
" %s 0x%lx
\n
"
,
aLang
.
getStr
(),
mnLangId
);
fprintf
(
stderr
,
"
\n
"
);
#endif
#endif
mnLangId
++
;
// hack - survive "x-no-translate"
if
(
aLang
.
equalsL
(
RTL_CONSTASCII_STRINGPARAM
(
"en-US"
)))
{
SetConstant
(
rNames
.
Put
(
"x-comment"
,
CONSTNAME
,
mnLangId
),
mnLangId
);
mnLangId
++
;
}
}
nIndex
++
;
nIndex
++
;
}
}
// hack - survive "x-no-translate"
/* XXX: that ^^^ was the original comment, but we're adding "x-comment"
* here? Which is good anyway. */
SetConstant
(
rNames
.
Put
(
"x-comment"
,
CONSTNAME
,
mnLangId
),
mnLangId
);
mnLangId
++
;
rtl
::
OString
aEnvIsoTokens
=
getenv
(
"RSC_LANG_ISO"
);
rtl
::
OString
aEnvIsoTokens
=
getenv
(
"RSC_LANG_ISO"
);
if
(
!
aEnvIsoTokens
.
isEmpty
()
)
if
(
!
aEnvIsoTokens
.
isEmpty
()
)
...
@@ -139,10 +126,12 @@ void RscLangEnum::Init( RscNameTable& rNames )
...
@@ -139,10 +126,12 @@ void RscLangEnum::Init( RscNameTable& rNames )
if
(
!
aIsoToken
.
isEmpty
()
)
if
(
!
aIsoToken
.
isEmpty
()
)
{
{
SetConstant
(
rNames
.
Put
(
aIsoToken
.
getStr
(),
CONSTNAME
,
mnLangId
),
mnLangId
);
SetConstant
(
rNames
.
Put
(
aIsoToken
.
getStr
(),
CONSTNAME
,
mnLangId
),
mnLangId
);
if
(
!
GetLangId
(
aIsoToken
))
bool
bAdd
=
(
GetLangId
(
aIsoToken
)
==
0
);
if
(
bAdd
)
ULong_Iso_map
[
aIsoToken
]
=
mnLangId
;
ULong_Iso_map
[
aIsoToken
]
=
mnLangId
;
#if OSL_DEBUG_LEVEL > 2
#if OSL_DEBUG_LEVEL > 2
fprintf
(
stderr
,
"Env ISO Language out: %s 0x%lx
\n
"
,
aIsoToken
.
getStr
(),
mnLangId
);
fprintf
(
stderr
,
"Env ISO Language out: %s 0x%lx (%s)
\n
"
,
aIsoToken
.
getStr
(),
mnLangId
,
(
bAdd
?
"added"
:
"exists"
)
);
#endif
#endif
mnLangId
++
;
mnLangId
++
;
}
}
...
@@ -166,20 +155,22 @@ void RscLangEnum::Init( RscNameTable& rNames )
...
@@ -166,20 +155,22 @@ void RscLangEnum::Init( RscNameTable& rNames )
Atom
RscLangEnum
::
AddLanguage
(
const
char
*
pLang
,
RscNameTable
&
rNames
)
Atom
RscLangEnum
::
AddLanguage
(
const
char
*
pLang
,
RscNameTable
&
rNames
)
{
{
Atom
nResult
=
0
;
Atom
nResult
=
0
;
bool
bAdd
=
false
;
KEY_STRUCT
aStruct
;
KEY_STRUCT
aStruct
;
if
(
!
rNames
.
Get
(
nResult
=
pHS
->
getID
(
pLang
),
&
aStruct
)
)
if
(
!
rNames
.
Get
(
nResult
=
pHS
->
getID
(
pLang
),
&
aStruct
)
)
{
{
SetConstant
(
nResult
=
rNames
.
Put
(
pLang
,
CONSTNAME
,
mnLangId
),
mnLangId
);
SetConstant
(
nResult
=
rNames
.
Put
(
pLang
,
CONSTNAME
,
mnLangId
),
mnLangId
);
// insert new lang to ULong_Iso_map
// insert new lang to ULong_Iso_map
rtl
::
OString
aLang
(
pLang
);
rtl
::
OString
aLang
(
pLang
);
if
(
!
GetLangId
(
aLang
))
bAdd
=
(
GetLangId
(
aLang
)
==
0
);
if
(
bAdd
)
ULong_Iso_map
[
aLang
]
=
mnLangId
;
ULong_Iso_map
[
aLang
]
=
mnLangId
;
// increase id counter
// increase id counter
mnLangId
++
;
mnLangId
++
;
}
}
#if OSL_DEBUG_LEVEL > 2
#if OSL_DEBUG_LEVEL > 2
fprintf
(
stderr
,
"AddLanguage(
%s ) = %d
\n
"
,
pLang
,
nResult
);
fprintf
(
stderr
,
"AddLanguage(
'%s' ) = %d (%s)
\n
"
,
pLang
,
nResult
,
(
bAdd
?
"added"
:
"exists"
)
);
#endif
#endif
return
nResult
;
return
nResult
;
}
}
...
...
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