Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
VLC-Android
Manage
Activity
Members
Labels
Plan
Issues
531
Issue boards
Milestones
Wiki
Code
Merge requests
14
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
VideoLAN
VLC-Android
Commits
70f5de75
Commit
70f5de75
authored
5 years ago
by
Nicolas Pomepuy
Committed by
Geoffrey Métais
5 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Improve supported language list
parent
cd3b1250
No related branches found
No related tags found
1 merge request
!69
Fix locale settings
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
vlc-android/build.gradle
+21
-0
21 additions, 0 deletions
vlc-android/build.gradle
vlc-android/src/org/videolan/vlc/gui/helpers/UiTools.java
+36
-36
36 additions, 36 deletions
vlc-android/src/org/videolan/vlc/gui/helpers/UiTools.java
with
57 additions
and
36 deletions
vlc-android/build.gradle
+
21
−
0
View file @
70f5de75
...
...
@@ -199,6 +199,27 @@ task generateSources (type: Jar) {
from
android
.
sourceSets
.
main
.
java
.
srcDirs
}
task
buildTranslationArray
<<
{
def
foundLocales
=
new
StringBuilder
()
foundLocales
.
append
(
"new String[]{"
)
fileTree
(
"res"
).
visit
{
FileVisitDetails
details
->
println
'details: '
+
details
if
(
details
.
file
.
path
.
endsWith
(
"strings.xml"
)){
def
languageCode
=
details
.
file
.
parent
.
tokenize
(
'/'
).
last
().
replaceAll
(
'values-'
,
''
).
replaceAll
(
'-r'
,
'-'
)
languageCode
=
(
languageCode
==
"values"
)
?
"en"
:
languageCode
;
foundLocales
.
append
(
"\""
).
append
(
languageCode
).
append
(
"\""
).
append
(
","
)
}
}
foundLocales
.
append
(
"}"
)
//Don't forget to remove the trailing comma
def
foundLocalesString
=
foundLocales
.
toString
().
replaceAll
(
',}'
,
'}'
)
android
.
defaultConfig
.
buildConfigField
"String[]"
,
"TRANSLATION_ARRAY"
,
foundLocalesString
}
preBuild
.
dependsOn
buildTranslationArray
dependencies
{
devImplementation
project
(
':libvlc'
)
devImplementation
project
(
':medialibrary'
)
...
...
This diff is collapsed.
Click to expand it.
vlc-android/src/org/videolan/vlc/gui/helpers/UiTools.java
+
36
−
36
View file @
70f5de75
...
...
@@ -32,6 +32,7 @@ import android.content.DialogInterface;
import
android.content.Intent
;
import
android.content.SharedPreferences
;
import
android.content.res.Configuration
;
import
android.content.res.Resources
;
import
android.content.res.TypedArray
;
import
android.graphics.Bitmap
;
import
android.graphics.drawable.BitmapDrawable
;
...
...
@@ -48,6 +49,7 @@ import android.renderscript.RenderScript;
import
android.renderscript.ScriptIntrinsicBlur
;
import
android.text.Html
;
import
android.text.TextUtils
;
import
android.util.DisplayMetrics
;
import
android.view.Display
;
import
android.view.DragAndDropPermissions
;
import
android.view.DragEvent
;
...
...
@@ -70,6 +72,7 @@ import org.videolan.libvlc.util.AndroidUtil;
import
org.videolan.medialibrary.Medialibrary
;
import
org.videolan.medialibrary.media.MediaLibraryItem
;
import
org.videolan.medialibrary.media.MediaWrapper
;
import
org.videolan.vlc.BuildConfig
;
import
org.videolan.vlc.MediaParsingService
;
import
org.videolan.vlc.R
;
import
org.videolan.vlc.VLCApplication
;
...
...
@@ -82,9 +85,11 @@ import org.videolan.vlc.util.LocalePair;
import
org.videolan.vlc.util.Settings
;
import
org.videolan.vlc.viewmodels.SortableModel
;
import
java.util.HashSet
;
import
java.util.List
;
import
java.util.Locale
;
import
java.util.Map
;
import
java.util.Set
;
import
java.util.TreeMap
;
import
androidx.annotation.NonNull
;
...
...
@@ -545,25 +550,7 @@ public class UiTools {
// Are we using advanced debugging - locale?
String
p
=
VLCApplication
.
getLocale
();
if
(!
p
.
equals
(
""
))
{
Locale
locale
;
// workaround due to region code
if
(
p
.
equals
(
"zh-TW"
))
{
locale
=
Locale
.
TRADITIONAL_CHINESE
;
}
else
if
(
p
.
startsWith
(
"zh"
))
{
locale
=
Locale
.
CHINA
;
}
else
if
(
p
.
equals
(
"pt-BR"
))
{
locale
=
new
Locale
(
"pt"
,
"BR"
);
}
else
if
(
p
.
equals
(
"bn-IN"
)
||
p
.
startsWith
(
"bn"
))
{
locale
=
new
Locale
(
"bn"
,
"IN"
);
}
else
{
/**
* Avoid a crash of
* java.lang.AssertionError: couldn't initialize LocaleData for locale
* if the user enters nonsensical region codes.
*/
if
(
p
.
contains
(
"-"
))
p
=
p
.
substring
(
0
,
p
.
indexOf
(
'-'
));
locale
=
new
Locale
(
p
);
}
Locale
locale
=
getLocaleFromString
(
p
);
Locale
.
setDefault
(
locale
);
final
Configuration
config
=
new
Configuration
();
config
.
locale
=
locale
;
...
...
@@ -588,30 +575,15 @@ public class UiTools {
}
public
static
LocalePair
getLocalesUsedInProject
(
Context
context
)
{
final
String
[]
localesEntryValues
=
context
.
getAssets
().
getLocales
()
;
final
String
[]
localesEntryValues
=
BuildConfig
.
TRANSLATION_ARRAY
;
final
String
[]
localesEntry
=
new
String
[
localesEntryValues
.
length
];
for
(
int
i
=
0
;
i
<
localesEntryValues
.
length
;
i
++)
{
final
String
localesEntryValue
=
localesEntryValues
[
i
];
String
language
;
String
country
=
""
;
//see if there is a language and a country
if
(
localesEntryValue
.
contains
(
"-"
))
{
String
[]
splittedLocale
=
localesEntryValue
.
split
(
"-"
);
if
(
splittedLocale
.
length
==
2
)
{
language
=
splittedLocale
[
0
];
country
=
splittedLocale
[
1
];
}
else
{
language
=
localesEntryValue
;
}
}
else
{
language
=
localesEntryValue
;
}
final
Locale
locale
=
new
Locale
(
language
,
country
);
Locale
locale
=
get
Locale
FromString
(
localesEntryValue
);
final
String
displayLanguage
=
locale
.
getDisplayLanguage
(
locale
);
final
String
displayCountry
=
locale
.
getDisplayCountry
(
locale
);
...
...
@@ -646,6 +618,34 @@ public class UiTools {
return
new
LocalePair
(
finalLocaleEntries
,
finalLocaleEntryValues
);
}
private
static
Locale
getLocaleFromString
(
String
string
)
{
/**
* See {@link android.content.res.AssetManager#getLocales()}
*/
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
LOLLIPOP
)
{
return
Locale
.
forLanguageTag
(
string
);
}
//Best effort on determining the locale
String
[]
separators
=
{
"_"
,
"-"
};
for
(
String
separator
:
separators
)
{
//see if there is a language and a country
if
(
string
.
contains
(
separator
))
{
String
[]
splittedLocale
=
string
.
split
(
separator
);
if
(
splittedLocale
.
length
==
2
)
{
return
new
Locale
(
splittedLocale
[
0
],
splittedLocale
[
1
]);
}
}
}
return
new
Locale
(
string
);
}
private
static
String
firstLetterUpper
(
String
string
)
{
if
(
string
==
null
)
{
return
null
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment