[squeak-dev] The Trunk: System-mt.1318.mcz
commits at source.squeak.org
commits at source.squeak.org
Thu Mar 10 13:21:35 UTC 2022
Marcel Taeumel uploaded a new version of System to project The Trunk:
http://source.squeak.org/trunk/System-mt.1318.mcz
==================== Summary ====================
Name: System-mt.1318
Author: mt
Time: 10 March 2022, 2:21:31.981707 pm
UUID: 1d4fe2d0-df8a-804b-88e7-c8315c0f238e
Ancestors: System-mt.1317
Clean up LocaleID and Locale.
Fixes the isse where the locale's "country" somehow stored the language name.
=============== Diff against System-mt.1317 ===============
Item was changed:
----- Method: ISOLanguageDefinition class>>extraCountryDefinitions (in category 'private') -----
extraCountryDefinitions
^{
+ {'KIDS'. 'KIDS'. 'KIDS'.}.
- {'Kids'. 'KIDS'. 'KIDS'.}.
}!
Item was changed:
----- Method: ISOLanguageDefinition class>>extraISO3Definitions (in category 'private') -----
extraISO3Definitions
^self readISOLanguagesFrom: 'jpk Japanese (Kids)
' readStream!
Item was changed:
----- Method: ISOLanguageDefinition class>>initISOCountries (in category 'private') -----
initISOCountries
"ISOLanguageDefinition initISOCountries"
| iso3166Table |
iso3166Table := ISOLanguageDefinition buildIso3166CodesTables.
ISO2Countries := Dictionary new.
ISO3Countries := Dictionary new.
iso3166Table do: [:entry |
+ (entry at: 2) ifNotEmpty: [:iso2 | ISO2Countries at: iso2 put: (entry at: 1)].
+ (entry at: 3) ifNotEmpty: [:iso3 | ISO3Countries at: iso3 put: (entry at: 1)]].
- ISO2Countries at: (entry at: 2) put: (entry at: 1).
- ISO3Countries at: (entry at: 3) put: (entry at: 1)].
self extraCountryDefinitions do: [:entry |
ISO2Countries at: (entry at: 2) put: (entry at: 1).
ISO3Countries at: (entry at: 3) put: (entry at: 1)]!
Item was changed:
----- Method: ISOLanguageDefinition class>>initialize (in category 'class initialization') -----
initialize
"ISOLanguageDefinition initialize"
ISO3Table := nil.
+ ISO2Table := nil.
+ ISO2Countries := nil.
+ ISO3Countries := nil.!
- ISO2Table := nil!
Item was changed:
----- Method: ISOLanguageDefinition class>>iso2LanguageTable (in category 'private') -----
iso2LanguageTable
"ISOLanguageDefinition iso2LanguageTable"
ISO2Table ifNotNil: [^ISO2Table].
ISO2Table := Dictionary new: self iso3LanguageTable basicSize.
+ self iso3LanguageTable do: [:entry | entry iso2 ifNotEmpty: [:iso2 |
+ ISO2Table at: iso2 put: entry]].
- self iso3LanguageTable do: [:entry |
- ISO2Table at: entry iso2 put: entry].
^ISO2Table!
Item was changed:
+ ----- Method: ISOLanguageDefinition class>>iso3166Codes (in category 'private - raw') -----
- ----- Method: ISOLanguageDefinition class>>iso3166Codes (in category 'private') -----
(excessive size, no diff calculated)
Item was changed:
+ ----- Method: ISOLanguageDefinition class>>isoLanguages (in category 'private - raw') -----
- ----- Method: ISOLanguageDefinition class>>isoLanguages (in category 'private') -----
isoLanguages
+ "ISO 639: 3-letter codes, http://www.loc.gov/standards/iso639-2/php/code_list.php"
- "ISO 639: 3-letter codes"
^'aar aa Afar
abk ab Abkhazian
ace Achinese
ach Acoli
ada Adangme
ady Adyghe; Adygei
afa Afro-Asiatic languages
afh Afrihili
afr af Afrikaans
ain Ainu
aka ak Akan
akk Akkadian
alb/sqi sq Albanian
ale Aleut
alg Algonquian languages
alt Southern Altai
amh am Amharic
ang English, Old (ca.450-1100)
anp Angika
apa Apache languages
ara ar Arabic
arc Official Aramaic (700-300 BCE); Imperial Aramaic (700-300 BCE)
arg an Aragonese
arm/hye hy Armenian
arn Mapudungun; Mapuche
arp Arapaho
art Artificial languages
arw Arawak
asm as Assamese
ast Asturian; Bable; Leonese; Asturleonese
ath Athapascan languages
aus Australian languages
ava av Avaric
ave ae Avestan
awa Awadhi
aym ay Aymara
aze az Azerbaijani
bad Banda languages
bai Bamileke languages
bak ba Bashkir
bal Baluchi
bam bm Bambara
ban Balinese
baq/eus eu Basque
bas Basa
bat Baltic languages
bej Beja; Bedawiyet
bel be Belarusian
bem Bemba
ben bn Bengali
ber Berber languages)
bho Bhojpuri
bih bh Bihari
bik Bikol
bin Bini; Edo
bis bi Bislama
bla Siksika
bnt Bantu languages
bos bs Bosnian
bra Braj
bre br Breton
btk Batak languages
bua Buriat
bug Buginese
bul bg Bulgarian
bur/mya my Burmese
byn Blin; Bilin
cad Caddo
cai Central American Indian languages
car Galibi Carib
cat ca Catalan; Valencian
cau Caucasian languages
ceb Cebuano
cel Celtic languages
cha ch Chamorro
chb Chibcha
che ce Chechen
chg Chagatai
chi/zho zh Chinese
chk Chuukese
chm Mari
chn Chinook jargon
cho Choctaw
chp Chipewyan; Dene Suline
chr Cherokee
chu cu Church Slavic; Old Slavonic; Church Slavonic; Old Bulgarian; Old Church Slavonic
chv cv Chuvash
chy Cheyenne
cmc Chamic languages
cop Coptic
cor kw Cornish
cos co Corsican
cpe Creoles and pidgins, English based
cpf Creoles and pidgins, French-based
cpp Creoles and pidgins, Portuguese-based
cre cr Cree
crh Crimean Tatar; Crimean Turkish
crp Creoles and pidgins
csb Kashubian
cus Cushitic languages
cze/ces cs Czech
dak Dakota
dan da Danish
dar Dargwa
day Land Dayak languages
del Delaware
den Slave (Athapascan)
dgr Dogrib
din Dinka
div dv Divehi; Dhivehi; Maldivian
doi Dogri
dra Dravidian languages
dsb Lower Sorbian
dua Duala
dum Dutch, Middle (ca.1050-1350)
dut/nld nl Dutch; Flemish
dyu Dyula
dzo dz Dzongkha
efi Efik
egy Egyptian (Ancient)
eka Ekajuk
elx Elamite
eng en English
enm English, Middle (1100-1500)
epo eo Esperanto
est et Estonian
ewe ee Ewe
ewo Ewondo
fan Fang
fao fo Faroese
fat Fanti
fij fj Fijian
fil Filipino; Pilipino
fin fi Finnish
fiu Finno-Ugrian languages)
fon Fon
fre/fra fr French
frm French, Middle (ca.1400-1600)
fro French, Old (842-ca.1400)
frr Northern Frisian
frs Eastern Frisian
fry fy Western Frisian
ful ff Fulah
fur Friulian
gaa Ga
gay Gayo
gba Gbaya
gem Germanic languages
geo/kat ka Georgian
ger/deu de German
gez Geez
gil Gilbertese
gla gd Gaelic; Scottish Gaelic
gle ga Irish
glg gl Galician
glv gv Manx
gmh German, Middle High (ca.1050-1500)
goh German, Old High (ca.750-1050)
gon Gondi
gor Gorontalo
got Gothic
grb Grebo
grc Greek, Ancient (to 1453)
gre/ell el Greek, Modern (1453-)
grn gn Guarani
gsw Swiss German; Alemannic; Alsatian
guj gu Gujarati
gwi Gwich''in
hai Haida
hat ht Haitian; Haitian Creole
hau ha Hausa
haw Hawaiian
heb he Hebrew
her hz Herero
hil Hiligaynon
him Himachali
hin hi Hindi
hit Hittite
hmn Hmong
hmo ho Hiri Motu
hrv hr Croatian
hsb Upper Sorbian
hun hu Hungarian
hup Hupa
iba Iban
ibo ig Igbo
ice/isl is Icelandic
ido io Ido
iii ii Sichuan Yi; Nuosu
ijo Ijo languages
iku iu Inuktitut
ile ie Interlingue; Occidental
ilo Iloko
ina ia Interlingua (International Auxiliary Language Association)
inc Indic languages
ind id Indonesian
ine Indo-European languages
inh Ingush
ipk ik Inupiaq
ira Iranian languages
iro Iroquoian languages
ita it Italian
jav jv Javanese
jbo Lojban
jpn ja Japanese
jpr Judeo-Persian
jrb Judeo-Arabic
kaa Kara-Kalpak
kab Kabyle
kac Kachin; Jingpho
kal kl Kalaallisut; Greenlandic
kam Kamba
kan kn Kannada
kar Karen languages
kas ks Kashmiri
kau kr Kanuri
kaw Kawi
kaz kk Kazakh
kbd Kabardian
kha Khasi
khi Khoisan languages
khm km Central Khmer
kho Khotanese; Sakan
kik ki Kikuyu; Gikuyu
kin rw Kinyarwanda
kir ky Kirghiz; Kyrgyz
kmb Kimbundu
kok Konkani
kom kv Komi
kon kg Kongo
kor ko Korean
kos Kosraean
kpe Kpelle
krc Karachay-Balkar
krl Karelian
kro Kru languages
kru Kurukh
kua kj Kuanyama; Kwanyama
kum Kumyk
kur ku Kurdish
kut Kutenai
lad Ladino
lah Lahnda
lam Lamba
lao lo Lao
lat la Latin
lav lv Latvian
lez Lezghian
lim li Limburgan; Limburger; Limburgish
lin ln Lingala
lit lt Lithuanian
lol Mongo
loz Lozi
ltz lb Luxembourgish; Letzeburgesch
lua Luba-Lulua
lub lu Luba-Katanga
lug lg Ganda
lui Luiseno
lun Lunda
luo Luo (Kenya and Tanzania)
lus Lushai
mac/mkd mk Macedonian
mad Madurese
mag Magahi
mah mh Marshallese
mai Maithili
mak Makasar
mal ml Malayalam
man Mandingo
mao/mri mi Maori
map Austronesian languages
mar mr Marathi
mas Masai
may/msa ms Malay
mdf Moksha
mdr Mandar
men Mende
mga Irish, Middle (900-1200)
mic Mi''kmaq; Micmac
min Minangkabau
mis Uncoded languages
mkh Mon-Khmer languages
mlg mg Malagasy
mlt mt Maltese
mnc Manchu
mni Manipuri
mno Manobo languages
moh Mohawk
mon mn Mongolian
mos Mossi
mul Multiple languages
mun Munda languages
mus Creek
mwl Mirandese
mwr Marwari
myn Mayan languages
myv Erzya
nah Nahuatl languages
nai North American Indian languages
nap Neapolitan
nau na Nauru
nav nv Navajo; Navaho
nbl nr Ndebele, South; South Ndebele
nde nd Ndebele, North; North Ndebele
ndo ng Ndonga
nds Low German; Low Saxon; German, Low; Saxon, Low
nep ne Nepali
new Nepal Bhasa; Newari
nia Nias
nic Niger-Kordofanian languages
niu Niuean
nno nn Norwegian Nynorsk; Nynorsk, Norwegian
nob nb Bokmal, Norwegian; Norwegian Bokmal
nog Nogai
non Norse, Old
nor no Norwegian
nqo N''Ko
nso Pedi; Sepedi; Northern Sotho
nub Nubian languages
nwc Classical Newari; Old Newari; Classical Nepal Bhasa
nya ny Chichewa; Chewa; Nyanja
nym Nyamwezi
nyn Nyankole
nyo Nyoro
nzi Nzima
oci oc Occitan (post 1500)
oji oj Ojibwa
ori or Oriya
orm om Oromo
osa Osage
oss os Ossetian; Ossetic
ota Turkish, Ottoman (1500-1928)
oto Otomian languages
paa Papuan languages
pag Pangasinan
pal Pahlavi
pam Pampanga; Kapampangan
pan pa Panjabi; Punjabi
pap Papiamento
pau Palauan
peo Persian, Old (ca.600-400 B.C.)
per/fas fa Persian
phi Philippine languages)
phn Phoenician
pli pi Pali
pol pl Polish
pon Pohnpeian
por pt Portuguese
pra Prakrit languages
pro Provencal, Old (to 1500);Occitan, Old (to 1500)
pus ps Pushto; Pashto
qaa-qtz Reserved for local use
que qu Quechua
raj Rajasthani
rap Rapanui
rar Rarotongan; Cook Islands Maori
roa Romance languages
roh rm Romansh
rom Romany
rum/ron ro Romanian; Moldavian; Moldovan
run rn Rundi
rup Aromanian; Arumanian; Macedo-Romanian
rus ru Russian
sad Sandawe
sag sg Sango
sah Yakut
sai South American Indian languages
sal Salishan languages
sam Samaritan Aramaic
san sa Sanskrit
sas Sasak
sat Santali
scn Sicilian
sco Scots
sel Selkup
sem Semitic languages
sga Irish, Old (to 900)
sgn Sign Languages
shn Shan
sid Sidamo
sin si Sinhala; Sinhalese
sio Siouan languages
sit Sino-Tibetan languages
sla Slavic languages
slo/slk sk Slovak
slv sl Slovenian
sma Southern Sami
sme se Northern Sami
smi Sami languages
smj Lule Sami
smn Inari Sami
smo sm Samoan
sms Skolt Sami
sna sn Shona
snd sd Sindhi
snk Soninke
sog Sogdian
som so Somali
son Songhai languages
sot st Sotho, Southern
spa es Spanish; Castilian
srd sc Sardinian
srn Sranan Tongo
srp sr Serbian
srr Serer
ssa Nilo-Saharan languages
ssw ss Swati
suk Sukuma
sun su Sundanese
sus Susu
sux Sumerian
swa sw Swahili
swe sv Swedish
syc Classical Syriac
syr Syriac
tah ty Tahitian
tai Tai languages
tam ta Tamil
tat tt Tatar
tel te Telugu
tem Timne
ter Tereno
tet Tetum
tgk tg Tajik
tgl tl Tagalog
tha th Thai
tib/bod bo Tibetan
tig Tigre
tir ti Tigrinya
tiv Tiv
tkl Tokelau
tlh Klingon; tlhIngan-Hol
tli Tlingit
tmh Tamashek
tog Tonga (Nyasa)
ton to Tonga (Tonga Islands)
tpi Tok Pisin
tsi Tsimshian
tsn tn Tswana
tso ts Tsonga
tuk tk Turkmen
tum Tumbuka
tup Tupi languages
tur tr Turkish
tut Altaic languages
tvl Tuvalu
twi tw Twi
tyv Tuvinian
udm Udmurt
uga Ugaritic
uig ug Uighur; Uyghur
ukr uk Ukrainian
umb Umbundu
und Undetermined
urd ur Urdu
uzb uz Uzbek
vai Vai
ven ve Venda
vie vi Vietnamese
vol vo Volapuk
vot Votic
wak Wakashan languages
wal Wolaitta; Wolaytta
war Waray
was Washo
wel/cym cy Welsh
wen Sorbian languages
wln wa Walloon
wol wo Wolof
xal Kalmyk; Oirat
xho xh Xhosa
yao Yao
yap Yapese
yid yi Yiddish
yor yo Yoruba
ypk Yupik languages
zap Zapotec
zbl Blissymbols; Blissymbolics; Bliss
zen Zenaga
zha za Zhuang; Chuang
znd Zande languages
zul zu Zulu
zun Zuni
zxx No linguistic content; Not applicable
zza Zaza; Dimili; Dimli; Kirdki; Kirmanjki; Zazaki'!
Item was changed:
----- Method: ISOLanguageDefinition class>>readISOLanguagesFrom: (in category 'private') -----
readISOLanguagesFrom: stream
"ISOLanguageDefinition readISOLanguagesFrom: ISOLanguageDefinition isoLanguages readStream "
| languages language code3 index line |
languages := Dictionary new.
[stream atEnd
or: [(line := stream nextLine readStream) atEnd]]
whileFalse: [
language := ISOLanguageDefinition new.
code3 := line upTo: Character tab.
(index := code3 indexOf: $/) > 0
ifTrue: [
language iso3: (code3 copyFrom: 1 to: index-1).
language iso3Alternate: (code3 copyFrom: index+1 to: code3 size)]
ifFalse: [language iso3: code3].
language
iso2: (line upTo: Character tab);
language: line upToEnd.
+ languages at: language iso3 put: language.
+ language iso3Alternate ifNotNil: [
+ languages at: language iso3Alternate put: language]].
- languages at: language iso3 put: language].
^languages!
Item was changed:
----- Method: ISOLanguageDefinition>>iso2 (in category 'accessing') -----
iso2
+ ^iso2 ifNil: ['']!
- ^iso2 ifNil: [self iso3]!
Item was changed:
Object subclass: #Locale
+ instanceVariableNames: 'id shortDate longDate time decimalSymbol digitGrouping currencySymbol currencyNotation measurement offsetLocalToUTC offsetVMToUTC dstActive leadingChar'
+ classVariableNames: 'Current CurrentPlatform KnownLocales Previous'
- instanceVariableNames: 'id shortDate longDate time decimalSymbol digitGrouping currencySymbol currencyNotation measurement offsetLocalToUTC offsetVMToUTC dstActive'
- classVariableNames: 'Current CurrentPlatform KnownLocales LanguageSymbols LocaleChangeListeners PlatformEncodings Previous'
poolDictionaries: ''
category: 'System-Localization'!
!Locale commentStamp: '<historical>' prior: 0!
Main comment stating the purpose of this class and relevant relationship to other classes.
http://www.w3.org/WAI/ER/IG/ert/iso639.htm
http://www.oasis-open.org/cover/iso639a.html
See also
http://oss.software.ibm.com/cvs/icu/~checkout~/icuhtml/design/language_code_issues.html
http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.10
ISO 3166
http://mitglied.lycos.de/buran/knowhow/codes/locales/
!
Item was removed:
- ----- Method: Locale class>>addLocalChangedListener: (in category 'notification') -----
- addLocalChangedListener: anObjectOrClass
- self localeChangedListeners add: anObjectOrClass!
Item was removed:
- ----- Method: Locale class>>clipboadInterpreter (in category 'accessing') -----
- clipboadInterpreter
- ^NoConversionClipboardInterpreter new!
Item was changed:
----- Method: Locale class>>current (in category 'accessing') -----
current
+
+ ^ Current ifNil: [Current := self currentPlatform]!
- "Current := nil"
- Current ifNil: [
- Current := self determineCurrentLocale.
- "Transcript show: 'Current locale: ' , Current localeID asString; cr"].
- ^Current!
Item was added:
+ ----- Method: Locale class>>current: (in category 'accessing') -----
+ current: locale
+
+ Current = locale ifTrue: [^ self].
+ Current := locale.
+ self localeChanged.!
Item was added:
+ ----- Method: Locale class>>current:during: (in category 'accessing') -----
+ current: locale during: aBlock
+ "Alter current language during a block"
+
+ | prior |
+ prior := self current.
+ [self current: locale. aBlock value]
+ ensure: [self current: prior].!
Item was changed:
+ ----- Method: Locale class>>currentPlatform (in category 'platform specific') -----
- ----- Method: Locale class>>currentPlatform (in category 'accessing') -----
currentPlatform
+
+ ^ CurrentPlatform ifNil: [CurrentPlatform := self new determineLocale]!
- "CurrentPlatform := nil"
- CurrentPlatform ifNil: [CurrentPlatform := self determineCurrentLocale].
- ^CurrentPlatform!
Item was changed:
+ ----- Method: Locale class>>currentPlatform: (in category 'platform specific') -----
- ----- Method: Locale class>>currentPlatform: (in category 'accessing') -----
currentPlatform: locale
+
+ CurrentPlatform := locale.!
- CurrentPlatform := locale.
- LanguageEnvironment startUp.
- !
Item was changed:
+ ----- Method: Locale class>>currentPlatform:during: (in category 'platform specific') -----
- ----- Method: Locale class>>currentPlatform:during: (in category 'accessing') -----
currentPlatform: locale during: aBlock
"Alter current language platform during a block"
+
+ | prior |
+ prior := self currentPlatform.
+ [self currentPlatform: locale. aBlock value]
+ ensure: [self currentPlatform: prior]!
- | backupPlatform |
- backupPlatform := self currentPlatform.
- [self currentPlatform: locale.
- aBlock value]
- ensure: [self currentPlatform: backupPlatform]!
Item was added:
+ ----- Method: Locale class>>default (in category 'constants') -----
+ default
+
+ ^ self localeID: LocaleID default!
Item was changed:
----- Method: Locale class>>defaultEncodingName: (in category 'platform specific') -----
+ defaultEncodingName: languageSymbol
+
+ self flag: #deprecated.
+ ^ (Locale isoString: languageSymbol) systemConverter class encodingNames first!
- defaultEncodingName: languageSymbol
- | encodings platformName osVersion |
- platformName := Smalltalk platformName.
- osVersion := Smalltalk getSystemAttribute: 1002.
- encodings := self platformEncodings at: languageSymbol
- ifAbsent: [self platformEncodings at: #default].
- encodings at: platformName ifPresent: [:encoding | ^encoding].
- encodings at: platformName , ' ' , osVersion
- ifPresent: [:encoding | ^encoding].
- ^encodings at: #default!
Item was changed:
----- Method: Locale class>>defaultInputInterpreter (in category 'platform specific') -----
defaultInputInterpreter
+
+ self flag: #deprecated.
+ ^ Locale currentPlatform inputInterpreter!
- | platformName |
- platformName := Smalltalk platformName.
- platformName = 'Win32' ifTrue: [^UTF32InputInterpreter new].
- ^NoInputInterpreter new!
Item was removed:
- ----- Method: Locale class>>determineCurrentLocale (in category 'private') -----
- determineCurrentLocale
- "For now just return the default locale.
- A smarter way would be to determine the current platforms default locale."
- "Locale determineCurrentLocale"
-
- ^self new determineLocale!
Item was changed:
----- Method: Locale class>>initKnownLocales (in category 'private') -----
initKnownLocales
| locales |
locales := Dictionary new.
"Init the locales for which we have translations"
+ NaturalLanguageTranslator availableLanguageLocaleIDs do: [:id |
- InternalTranslator availableLanguageLocaleIDs do: [:id |
locales at: id put: (Locale new localeID: id)].
^locales!
Item was changed:
----- Method: Locale class>>initialize (in category 'class initialization') -----
initialize
"Locale initialize"
+
+ Smalltalk addToStartUpList: Locale before: NaturalLanguageTranslator.
+
- Smalltalk addToStartUpList: Locale.
Preferences
addPreference: #useLocale
categories: #('general' )
default: false
balloonHelp: 'Use the system locale to set the system language, etc., at startup. For time-zone handling, see automaticTimezone.'!
Item was removed:
- ----- Method: Locale class>>initializePlatformEncodings (in category 'class initialization') -----
- initializePlatformEncodings
- "Locale initializePlatformEncodings"
-
- | platform |
- PlatformEncodings isNil ifTrue: [ PlatformEncodings := Dictionary new ].
-
- platform := PlatformEncodings at: 'default' ifAbsentPut: Dictionary new.
- platform
- at: 'default' put: 'iso8859-1';
- at: 'Win32 CE' put: 'utf-8';
- yourself.
-
- platform := PlatformEncodings at: 'ja' ifAbsentPut: Dictionary new.
- platform
- at: 'default' put: 'shift-jis';
- at: 'unix' put: 'euc-jp';
- at: 'Win32 CE' put: 'utf-8';
- yourself.
-
- platform := PlatformEncodings at: 'ko' ifAbsentPut: Dictionary new.
- platform
- at: 'default' put: 'euc-kr';
- at: 'Win32 CE' put: 'utf-8';
- yourself.
-
- platform := PlatformEncodings at: 'zh' ifAbsentPut: Dictionary new.
- platform
- at: 'default' put: 'gb2312';
- at: 'unix' put: 'euc-cn';
- at: 'Win32 CE' put: 'utf-8';
- yourself.
- !
Item was changed:
+ ----- Method: Locale class>>isoLanguage: (in category 'instance lookup') -----
- ----- Method: Locale class>>isoLanguage: (in category 'accessing') -----
isoLanguage: isoLanguage
^self isoLanguage: isoLanguage isoCountry: nil!
Item was changed:
+ ----- Method: Locale class>>isoLanguage:isoCountry: (in category 'instance lookup') -----
- ----- Method: Locale class>>isoLanguage:isoCountry: (in category 'accessing') -----
isoLanguage: isoLanguage isoCountry: isoCountry
^self localeID: (LocaleID isoLanguage: isoLanguage isoCountry: isoCountry)!
Item was changed:
----- Method: Locale class>>isoLocale: (in category 'accessing') -----
isoLocale: aString
+
+ self deprecated.
+ ^ self isoString: aString !
- !
Item was added:
+ ----- Method: Locale class>>isoString: (in category 'instance lookup') -----
+ isoString: aString
+
+ ^self localeID: (LocaleID isoString: aString)!
Item was changed:
----- Method: Locale class>>languageSymbol: (in category 'accessing') -----
languageSymbol: languageSymbol
"Locale languageSymbol: #Deutsch"
+ self flag: #deprecated.
+ ^ self isoLanguage: (languageSymbol caseOf: {
+ [#Deutsch] -> ['de']. [#Englisch] -> ['en']. [#Französisch] -> ['fr'].
+ [#German] -> ['de']. [#English] -> ['en']. [#French] -> ['fr'].
+ [#Allemand] -> ['de']. [#Anglais] -> ['en']. [#Français] -> ['fr']})!
- ^self isoLanguage: (LanguageSymbols at: languageSymbol)!
Item was removed:
- ----- Method: Locale class>>localeChangedListeners (in category 'notification') -----
- localeChangedListeners
- ^LocaleChangeListeners ifNil: [LocaleChangeListeners := OrderedCollection new]!
Item was changed:
+ ----- Method: Locale class>>localeID: (in category 'instance lookup') -----
- ----- Method: Locale class>>localeID: (in category 'accessing') -----
localeID: id
^self knownLocales at: id ifAbsentPut: [Locale new localeID: id]!
Item was removed:
- ----- Method: Locale class>>platformEncodings (in category 'class initialization') -----
- platformEncodings
- PlatformEncodings isEmptyOrNil ifTrue: [ self initializePlatformEncodings ].
- ^PlatformEncodings
- !
Item was added:
+ ----- Method: Locale class>>previous: (in category 'accessing') -----
+ previous: aLocale
+ Previous := aLocale
+ !
Item was changed:
----- Method: Locale class>>startUp: (in category 'system startUp') -----
startUp: resuming
+
resuming ifFalse: [^self].
+ self currentPlatform: nil.
+
+ (Preferences valueOfFlag: #useLocale) ifTrue: [
+ self currentPlatform ~= self current ifTrue: [
+ self
+ switchToID: self currentPlatform localeID
+ gently: true]].!
- (Preferences valueOfFlag: #useLocale)
- ifTrue: [
- | newID |
- newID := self current determineLocaleID.
- newID ~= LocaleID current
- ifTrue: [self switchAndInstallFontToID: newID gently: true]]!
Item was changed:
----- Method: Locale class>>switchAndInstallFontToID: (in category 'accessing') -----
switchAndInstallFontToID: localeID
"Locale switchAndInstallFontToID: (LocaleID isoLanguage: 'de')"
+
+ self flag: #deprecated.
+ ^ self switchAndInstallFontToID: localeID gently: false!
- | locale |
- locale := Locale localeID: localeID.
- locale languageEnvironment isFontAvailable
- ifFalse: [(self confirm: 'This language needs additional fonts.
- Do you want to install the fonts?' translated)
- ifTrue: [locale languageEnvironment installFont]
- ifFalse: [^ self]].
- self
- switchTo: locale!
Item was changed:
----- Method: Locale class>>switchAndInstallFontToID:gently: (in category 'accessing') -----
switchAndInstallFontToID: localeID gently: gentlyFlag
+ "Change the system's locale to the given localeID. The gentlyFlag can be used to implement a less aggressive version of object updates. NOTE THAT the user is prompted to install missing fonts if not available."
+
+ | locale env |
- | locale result env envFound ret fontInImage menu |
- "Logic:
- - not in Rainbow,
- - if the font is in the image, use the font.
- - if the font is not in the image,
- - ask to choose:
- - load font
- - try to enable pango, if pango is available
- - or cancel.
- - if the previous step fails, notify the user that you cannot switch to the language.
- Details:
- - how to check non-pango font is available:
- - if the language environment for the locale doesn't exist, the font is not available.
- - if font loading fails, it is not available.
- - how to check if the language environment doesn't exist:
- - if the locales languageEnvironment is Latin1 but the locale isn't it is not available.
- "
locale := Locale localeID: localeID.
env := locale languageEnvironment.
+
+ self flag: #deprecated.
+ env isFontAvailable ifFalse: [
+ (self confirm: 'This language needs additional fonts.\Do you want to install the fonts?' translated withCRs)
+ ifFalse: [^ self].
+ env installFont].
+
+ ^ self switchTo: locale gently: gentlyFlag!
- result := true.
- envFound := (Latin1Environment supportedLanguages includes: locale isoLanguage) or: [(env isMemberOf: Latin1Environment) not].
- fontInImage := envFound and: [env isFontAvailable].
- fontInImage ifFalse: [
- menu := MenuMorph new.
- menu defaultTarget: menu.
- envFound ifTrue: [menu add: 'load font' translated selector: #modalSelection: argument: #loadFont].
- menu add: 'cancel' translated selector: #modalSelection: argument: #cancel.
- menu addTitle: 'This language needs additional fonts.
- Do you want to install the fonts?' translated.
- ret := menu invokeModal.
- ret = #loadFont ifTrue: [result := env installFont. result ifTrue: [AbstractFont setupDefaultFallbackTextStyle]].
- (ret ~~ #loadFont and: [ret ~~ #enablePango]) ifTrue: [result := false]].
- result ifFalse: [self inform: 'Cannot load additional fonts' translated] ifTrue: [self switchTo: locale gently: gentlyFlag].
- !
Item was changed:
----- Method: Locale class>>switchTo:gently: (in category 'accessing') -----
switchTo: locale gently: gentlyFlag
+ "Change the system's locale, which also changes the current natural-language translator."
"Locale switchTo: (Locale isoLanguage: 'de')"
+
+ self current = locale ifTrue: [^ self].
+
+ Previous := Current.
+ Current := locale.
+
+ gentlyFlag
+ ifTrue: [self localeChangedGently]
+ ifFalse: [self localeChanged].!
- | availableID |
- availableID := (NaturalLanguageTranslator availableForLocaleID: locale localeID) localeID.
- Current localeID = availableID
- ifFalse: [Previous := Current.
- CurrentPlatform := Current := Locale localeID: availableID.
- gentlyFlag ifTrue: [self localeChangedGently] ifFalse: [self localeChanged]]!
Item was added:
+ ----- Method: Locale class>>switchToID:gently: (in category 'accessing') -----
+ switchToID: localeID gently: gentlyFlag
+
+ self switchTo: (Locale localeID: localeID) gently: gentlyFlag!
Item was added:
+ ----- Method: Locale>>= (in category 'comparing') -----
+ = other
+
+ ^ self class == other class
+ and: [self localeID = other localeID]!
Item was added:
+ ----- Method: Locale>>clipboardInterpreter (in category 'accessing - queries') -----
+ clipboardInterpreter
+
+ ^ self languageEnvironment clipboardInterpreter!
Item was changed:
+ ----- Method: Locale>>determineLocale (in category 'initialize-release') -----
- ----- Method: Locale>>determineLocale (in category 'accessing') -----
determineLocale
self localeID: self determineLocaleID!
Item was changed:
+ ----- Method: Locale>>determineLocaleID (in category 'initialize-release') -----
- ----- Method: Locale>>determineLocaleID (in category 'accessing') -----
determineLocaleID
"Locale current determineLocaleID"
+
+ ^ LocaleID
+ isoLanguage: (self fetchISO2Language ifNil: ['en'])
+ isoCountry: self fetchISOCountry!
- | isoLang isoCountry |
- isoLang := self fetchISO2Language
- ifNil: [^ self localeID].
- isoCountry := self fetchISOCountry
- ifNil: [^ LocaleID isoLanguage: isoLang].
- ^ LocaleID isoLanguage: isoLang isoCountry: isoCountry!
Item was changed:
+ ----- Method: Locale>>fetchISO2Language (in category 'initialize-release') -----
- ----- Method: Locale>>fetchISO2Language (in category 'private') -----
fetchISO2Language
"Locale current fetchISO2Language"
| lang isoLang |
lang := self primLanguage.
lang ifNil: [^nil].
lang := lang copyUpTo: 0 asCharacter.
lang size == 2
ifTrue: [^lang].
isoLang := ISOLanguageDefinition iso3LanguageDefinition: lang.
^isoLang
ifNil: [nil]
ifNotNil: [isoLang iso2]!
Item was changed:
+ ----- Method: Locale>>fetchISOCountry (in category 'initialize-release') -----
- ----- Method: Locale>>fetchISOCountry (in category 'private') -----
fetchISOCountry
"Locale current fetchISOCountry"
| countryCode |
countryCode := self primCountry
ifNil: [^ nil].
^ countryCode copyUpTo: 0 asCharacter!
Item was added:
+ ----- Method: Locale>>fileNameConverter (in category 'accessing - queries') -----
+ fileNameConverter
+
+ ^ self languageEnvironment fileNameConverter!
Item was added:
+ ----- Method: Locale>>fileNameEncodingName (in category 'accessing - queries') -----
+ fileNameEncodingName
+
+ ^ self languageEnvironment fileNameConverter class encodingNames first !
Item was added:
+ ----- Method: Locale>>hash (in category 'comparing') -----
+ hash
+ "Mix in class hash to not confuse with LocaleID hash:"
+
+ ^ self class hash bitXor: self localeID hash!
Item was changed:
+ ----- Method: Locale>>iconForNativeLanguage (in category 'accessing - queries') -----
- ----- Method: Locale>>iconForNativeLanguage (in category 'accessing') -----
iconForNativeLanguage
^ (NaturalLanguageFormTranslator localeID: self localeID) translate: 'LanguageNameInNativeLanguage'.
!
Item was added:
+ ----- Method: Locale>>inputInterpreter (in category 'accessing - queries') -----
+ inputInterpreter
+
+ ^ self languageEnvironment inputInterpreter!
Item was changed:
+ ----- Method: Locale>>isoCountry (in category 'accessing - queries') -----
- ----- Method: Locale>>isoCountry (in category 'accessing') -----
isoCountry
^self localeID isoCountry!
Item was changed:
+ ----- Method: Locale>>isoLanguage (in category 'accessing - queries') -----
- ----- Method: Locale>>isoLanguage (in category 'accessing') -----
isoLanguage
^self localeID isoLanguage!
Item was changed:
+ ----- Method: Locale>>isoLocale (in category 'accessing - queries') -----
- ----- Method: Locale>>isoLocale (in category 'accessing') -----
isoLocale
+
+ self deprecated.
+ ^ self localeID isoString!
- "<language>-<country>"
- ^self isoCountry
- ifNil: [self isoLanguage]
- ifNotNil: [self isoLanguage , '-' , self isoCountry]!
Item was changed:
----- Method: Locale>>languageEnvironment (in category 'accessing') -----
languageEnvironment
+ "Answer the language environment that is available for the receiver's locale ID. NOTE THAT client code should always query the language environment of the platform locale!!"
+
+ ^ self localeID languageEnvironment!
- ^LanguageEnvironment localeID: self localeID!
Item was added:
+ ----- Method: Locale>>languageTranslator (in category 'accessing') -----
+ languageTranslator
+
+ ^ self localeID languageTranslator!
Item was added:
+ ----- Method: Locale>>leadingChar (in category 'accessing') -----
+ leadingChar
+ "Cached here because of Unicode class >> #value:."
+
+ ^ leadingChar ifNil: [leadingChar := self languageEnvironment leadingChar]!
Item was changed:
+ ----- Method: Locale>>offsetLocalToUTC (in category 'accessing - queries') -----
- ----- Method: Locale>>offsetLocalToUTC (in category 'accessing') -----
offsetLocalToUTC
^self primTimezone!
Item was changed:
+ ----- Method: Locale>>printOn: (in category 'printing') -----
- ----- Method: Locale>>printOn: (in category 'accessing') -----
printOn: aStream
+
super printOn: aStream.
+ aStream
+ nextPut: $(;
+ print: id;
+ nextPut: $)!
- aStream nextPutAll: '(' , id printString , ')'!
Item was added:
+ ----- Method: Locale>>systemConverter (in category 'accessing - queries') -----
+ systemConverter
+
+ ^ self languageEnvironment systemConverter!
Item was changed:
Object subclass: #LocaleID
instanceVariableNames: 'isoLanguage isoCountry'
classVariableNames: ''
poolDictionaries: ''
category: 'System-Localization'!
+
+ !LocaleID commentStamp: 'mt 1/26/2022 10:46' prior: 0!
+ I am an identifier for a Locale. My structure consists of a code for a language and a code for a country according to ISO 639 and ISO 3166 respectively. The country may specialize a language but it is not required.
+
+ Here are some print-it/inspect-it examples:
+
+ LocaleID isoString: 'en'
+ LocaleID isoString: 'en-US'
+ LocaleID isoString: 'en-GB'
+ LocaleID isoString: 'fr'
+ LocaleID isoString: 'fr-FR'
+ LocaleID isoString: 'de'
+ LocaleID isoString: 'de-DE'
+ LocaleID isoString: 'de-CH'
+ LocaleID isoString: 'de-AT'
+
+ Note that any specialized identifier (e.g., 'en-US') has a generic #parent (e.g., 'en'). Try to favor the generic form whenver possible. You can use the specialized form, e.g., when translating natural language.
+
+ Take a look at ISOLanguageDefinition to understand how the codes are expanded to language names and country names. You can also use 3-letter codes:
+
+ LocaleID isoString: 'eng-USA'
+ LocaleID isoString: 'fre-FRA'
+ LocaleID isoString: 'deu-CHE'
+
+ BE AWARE that you cannot compare (i.e. #=) a 2-letter id with a 3-letter id. So, make consistent use of either form only.!
Item was removed:
- ----- Method: LocaleID class>>countryFor: (in category 'accessing') -----
- countryFor: iso6391Code
- "http://www.loc.gov/standards/iso639-2/php/code_list.php"
- ^ iso6391Code
- caseOf:
- { ['af'] -> ['Afrikaans'].
- ['ca'] -> ['Catalan'].
- ['cs'] -> [ 'Czech'].
- ['da'] -> [ 'Danish'].
- ['de'] -> [ 'German'].
- ['el'] -> [ 'Greek Modern'].
- ['en'] -> [ 'English'].
- ['es'] -> [ 'Spanish'].
- ['eu'] -> [ 'Basque'].
- ['fi'] -> [ 'Finnish'].
- ['fo'] -> [ 'Faroese'].
- ['fr'] -> [ 'French'].
- ['ga'] -> [ 'Irish'].
- ['gd'] -> [ 'Gaelic'].
- ['hr'] -> [ 'Croatian'].
- ['hu'] -> [ 'Hungarian'].
- ['is'] -> [ 'Icelandic'].
- ['it'] -> [ 'Italian'].
- ['ja'] -> [ 'Japanese'].
- ['ja-etoys'] -> [ 'Japanese'].
- ['ko'] -> [ 'Korean'].
- ['nl'] -> [ 'Dutch'].
- ['no'] -> [ 'Norwegian'].
- ['pt'] -> [ 'Portuguese'].
- ['rm'] -> [ 'Romansh'].
- ['ro'] -> [ 'Romainian'].
- ['sk'] -> [ 'Slovak'].
- ['sl'] -> [ 'Slovenian'].
- ['sq'] -> [ 'Albanian'].
- ['sv'] -> [ 'Swedish'].
- ['sw'] -> [ 'Swahili'].
- ['zh'] -> [ 'Chinese'] }
- otherwise:
- [ 'other' ]!
Item was added:
+ ----- Method: LocaleID class>>default (in category 'constants') -----
+ default
+
+ ^ self isoLanguage: 'en'!
Item was changed:
----- Method: LocaleID>>displayCountry (in category 'accessing') -----
displayCountry
+
+ ^ self hasIsoCountry ifFalse: [ '' ] ifTrue: [
+ ISOLanguageDefinition iso2Countries
+ at: self isoCountry
+ ifAbsent: [ ISOLanguageDefinition iso3Countries
+ at: self isoCountry
+ ifAbsent: [ self isoCountry ]]] !
- ^(ISOLanguageDefinition iso2Countries at: self isoCountry asUppercase ifAbsent: [ self isoCountry ]) !
Item was changed:
----- Method: LocaleID>>displayLanguage (in category 'accessing') -----
displayLanguage
| language |
language := (ISOLanguageDefinition iso2LanguageTable
at: self isoLanguage
+ ifAbsent: [ISOLanguageDefinition iso3LanguageTable
+ at: self isoLanguage
+ ifAbsent: [^ self isoLanguage]]) language.
+ ^ self displayCountry
+ ifEmpty: [language]
+ ifNotEmpty: [:dc | language , ' (' , dc , ')']!
- ifAbsent: [^ self isoLanguage]) language.
- ^ self isoCountry
- ifNil: [language]
- ifNotNil: [language , ' (' , self displayCountry , ')']!
Item was changed:
----- Method: LocaleID>>displayName (in category 'accessing') -----
displayName
"Answer a proper name to represent the receiver in GUI.
The wording is provided by translations of the magic value
'<language display name>'.
'English' -> 'English'
'German' -> 'Deutsch'
"
| magicPhrase translatedMagicPhrase |
+ magicPhrase := 'Language-Name' translatedNoop.
+ translatedMagicPhrase := self languageTranslator translate: magicPhrase.
- magicPhrase := '<language display name>'.
- translatedMagicPhrase := NaturalLanguageTranslator translateWithoutLoading: magicPhrase toLocaleID: self.
^ translatedMagicPhrase = magicPhrase
ifTrue: [self displayLanguage]
ifFalse: [translatedMagicPhrase]!
Item was added:
+ ----- Method: LocaleID>>hasIsoCountry (in category 'testing') -----
+ hasIsoCountry
+
+ ^ isoCountry notNil!
Item was changed:
----- Method: LocaleID>>hasParent (in category 'testing') -----
hasParent
+
+ ^self hasIsoCountry!
- ^self isoCountry notNil!
Item was removed:
- ----- Method: LocaleID>>isoCountry: (in category 'accessing') -----
- isoCountry: aValue
-
- isoCountry := aValue!
Item was changed:
----- Method: LocaleID>>isoLanguage:isoCountry: (in category 'initialize') -----
+ isoLanguage: langString isoCountry: countryStringOrNil
+
+ isoLanguage := langString asLowercase.
+ isoCountry := countryStringOrNil ifNotNil: [:c | c ifEmpty: [nil] ifNotEmpty: [c asUppercase]].
+ !
- isoLanguage: langString isoCountry: countryStringOrNil
- isoLanguage := langString.
- isoCountry := countryStringOrNil ifNil: (self class countryFor: langString)!
Item was changed:
----- Method: LocaleID>>isoString (in category 'accessing') -----
isoString
+ "<language>-<country>"
+
+ ^ String streamContents: [:stream |
+ stream nextPutAll: self isoLanguage.
+ self hasIsoCountry ifTrue: [
+ stream nextPut: $-; nextPutAll: self isoCountry]]!
- ^self asString!
Item was added:
+ ----- Method: LocaleID>>languageEnvironment (in category 'accessing') -----
+ languageEnvironment
+
+ ^ LanguageEnvironment forLocaleID: self!
Item was added:
+ ----- Method: LocaleID>>languageTranslator (in category 'accessing') -----
+ languageTranslator
+ "Answer the implicit translator for the receiver. Try GetText first."
+
+ ^ GetTextTranslator forLocaleID: self ifAbsent: [InternalTranslator forLocaleID: self]!
Item was changed:
----- Method: LocaleID>>parent (in category 'accessing') -----
parent
+ ^self class isoLanguage: self isoLanguage!
- ^ (self class
- isoLanguage: self isoLanguage)
- isoCountry: nil;
- yourself!
Item was changed:
+ ----- Method: LocaleID>>posixName (in category 'accessing') -----
- ----- Method: LocaleID>>posixName (in category 'printing') -----
posixName
"(LocaleID isoString: 'es-MX') posixName"
"(LocaleID isoString: 'es') posixName"
"language[_territory]"
+ ^ self hasIsoCountry
+ ifFalse: [self isoLanguage]
+ ifTrue: [self isoLanguage , '_' , self isoCountry]!
- ^ self isoCountry
- ifNil: [self isoLanguage]
- ifNotNil: [self isoLanguage , '_' , self isoCountry]!
Item was changed:
----- Method: LocaleID>>printOn: (in category 'printing') -----
printOn: stream
+
+ stream
+ nextPutAll: self isoString;
+ space; nextPut: $<;
+ nextPutAll: self displayLanguage;
+ nextPut: $>.!
- "<language>-<country>"
- stream nextPutAll: self isoLanguage.
- self isoCountry
- ifNotNil: [stream nextPut: $-; nextPutAll: self isoCountry]!
Item was changed:
----- Method: LocaleID>>storeOn: (in category 'printing') -----
storeOn: aStream
+
aStream nextPut: $(.
aStream nextPutAll: self class name.
aStream nextPutAll: ' isoString: '.
+ aStream store: self isoString.
- aStream nextPutAll: '''' , self printString , ''''.
aStream nextPut: $).
!
Item was changed:
----- Method: LocaleID>>translator (in category 'accessing') -----
translator
+
+ self flag: #deprecated.
+ ^ self languageTranslator!
- ^ InternalTranslator localeID: self !
Item was added:
+ ----- Method: NaturalLanguageTranslator class>>cachedTranslations (in category 'accessing') -----
+ cachedTranslations
+
+ ^ Dictionary new!
Item was added:
+ ----- Method: NaturalLanguageTranslator class>>forLocaleID: (in category 'accessing') -----
+ forLocaleID: localeID
+
+ ^ self localeID: localeID!
Item was added:
+ ----- Method: NaturalLanguageTranslator class>>forLocaleID:ifAbsent: (in category 'accessing') -----
+ forLocaleID: localeID ifAbsent: aBlock
+
+ ^ self localeID: localeID!
Item was changed:
+ (PackageInfo named: 'System') postscript: 'Locale resetKnownLocales.
+ Locale current: nil.
+ Locale currentPlatform: nil.'!
- (PackageInfo named: 'System') postscript: 'UserInterfaceTheme cleanUpAndReset. "Reduces keyboardFocusWidth in themes because we now add borderWidth of scrollables extra. See Morph >> #drawKeyboardFocusIndicationOn:."'!
More information about the Squeak-dev
mailing list
|