You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Work for release 0.1.1
- Mostly cosmetic cleanup of plugin tasks to improve functional organization, readability, and logging
- Unit test validation added for plugin and all individual tasks
- Java/Android locales lists added as docs as user information
- Update README with more streamlined instructions, linked to wiki for more info
Related work on Github
- PR tests workflow added to validate changes before merging
- Add deeper config details and locale information to wiki
- Add roadmap to Discussions
A Gradle plugin for Android projects to automate locale configuration and provide supporting source/resource files.
4
-
Built with Android Gradle Plugin (AGP) 7.4.0
4
+
Built with Android Gradle Plugin (AGP) 7.5.0
5
5
6
-
## Primary Function
6
+
## Functionality
7
7
8
-
This plugin was built mostly to generate `locale-config.xml` file to support [per-app language settings](https://developer.android.com/guide/topics/resources/app-languages) for Android API 33+. Instead of remembering to modify files each time you add support for a locale, you just add the locale _once_ into your build.gradle file and let this plugin generate the xml resources you need for locale support.
8
+
- Generates `locale-config.xml` file for Android [per-app language settings](https://developer.android.com/guide/topics/resources/app-languages)
9
+
- Generates `SupportedLocales` Kotlin class for in-app access to your configured locales
10
+
- Includes pseudolocale support when pseudolocales enabled for build variant
9
11
10
-
**Bonus:** The plugin automatically includes pseudolocale options if you have them enabled for a build variant.
12
+
## Community and Docs
11
13
12
-
## Secondary Functions
14
+
-[Wiki](../../wiki) for more details on language tag support and plugin configuration
15
+
-[Discussions](../../discussions) for project roadmap, ideas, Q&A, and polls
16
+
-[Issues](../../issues) for found bugs and reporting specific locale issues
13
17
14
-
A `SupportedLocales.kt` source file is generated with maps of the locales your app is set to support. It includes language tags, langauge names (both exonyms and endonyms provided), and functions to get them. This data is intended to assist with building an in-app language selector, but I'd love to hear about other uses.
18
+
## Setup
15
19
16
-
##How to Use
20
+
### Plugin Dependency Management
17
21
18
22
```kotlin
19
-
// settings.gradle.kts (project settings)
23
+
// File - settings.gradle.kts (project settings)
24
+
20
25
dependencyResolutionManagement {
21
-
//should already have this section, don't modify
26
+
// don't modify
22
27
}
23
28
24
29
// add this if you don't have it
@@ -30,22 +35,24 @@ pluginManagement {
30
35
}
31
36
```
32
37
33
-
The `resourceConfigurations` property below is a list of explicitly configured resource types to be added to your project. Often, it's used to prevent building your project with extra resources you don't need (like tons of locale resources you don't support coming from dependencies you didn't know hda them.)
38
+
### Project Locale Configuration
39
+
40
+
The `resourceConfigurations` property is a list of explicitly configured resource types to be added to your project. Often, it's used to prevent building your project with extra resources you don't need (like locale resources you don't support coming from project dependencies)
34
41
35
-
Since it's good practice to specify resources in use, this plugin utilizes the same `resourceConfigurations` list in during generation. Just add your supported locales into this list, and the plugin will handle the rest!
42
+
Since it's good practice to specify resources in use, this plugin utilizes the same `resourceConfigurations` list to guide its resource generation. Add your supported locales into this list, and the plugin will handle the rest!
36
43
37
44
```kotlin
38
-
// build.gradle.kts (application level)
45
+
// File - build.gradle.kts (app module)
46
+
39
47
plugins {
40
48
//...
41
-
id("com.mermake.locale-resource-generator") version "0.1"// check release page for latest version
49
+
id("com.mermake.locale-resource-generator") version "{{latest}}"
42
50
}
43
51
44
52
android {
45
53
//...
46
54
defaultConfig {
47
55
//...
48
-
49
56
resourceConfigurations.addAll(
50
57
listOf(
51
58
"en",
@@ -60,16 +67,17 @@ android {
60
67
}
61
68
}
62
69
```
63
-
> Notice the different formats of the language tags below. They're not _quite_ Unicode tags, but it's okay. Android recognizes both the `xx-rXX` and `bxx+XX+` formats ([more info on locale resolution here](https://developer.android.com/guide/topics/resources/multilingual-support#postN)). This is important to know since some language tags like `de-DE` would cause a build failure and the `b+` format is required. ([BCP-47 spec](https://cldr.unicode.org/development/development-process/design-proposals/bcp47-syntax-mapping)) In any case, the plugin converts everything to Unicode-friendly tags since that what we need in the manifest and source code anyway.
70
+
> See the wiki page on [Locales and Android Support](../../wiki/Locales-and-Android-Support) for details on supported language tags.
71
+
72
+
### Manifest Configuration
64
73
65
74
```xml
66
75
<!-- AndroidManifest.xml -->
67
76
<application>
68
-
<!-- Include this line in your application tag. The file is generated when you build and resolves without issue. -->
77
+
<!-- Include this line in your application tag. The file is generated when you build or run the locale config task. -->
69
78
android:localeConfig="@xml/locale_config"
70
-
71
-
72
-
<!-- Add this for supporting lower than API 33 (see linked Android docs for more details) -->
79
+
80
+
<!-- Add this for supporting lower than API 33 (see Android docs for more info) -->
The plugin runs automatically as part of your normal builds. You can also run individual tasks:
85
-
-`generateLocaleConfig[Debug|Release|etc]` - generates `locale_config.xml` file for per-app language support
86
-
87
-
## Glossary
88
-
89
-
-**Endonym** - A name used by a group or category of people to refer to themselves or their language, as opposed to a name given to them by other groups.
90
-
- In Germany (Deutcshland), the 'German' language is written as 'Deutsche'
91
-
- In Japan (日本), the 'Japanese' language is written as '日本語'
92
-
92
+
## Gradle Tasks
93
93
94
-
-**Exonym** - Opposite of exonym. A name used to refer to a language or people that is not what they use to refer to themsleves their own language. Many languages have different names for each language.
95
-
- 'French' in Japanese is 'フランス語'
96
-
- 'French' in German is 'Französisch'
94
+
The plugin runs its tasks automatically before the `preBuild` step of your normal builds. A variant task is configured for each of your project's build variants. (debug, release, wumbo, etc.)
0 commit comments