Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/rikkaapps/autoresconfig
A gradle plugin generates resConfig & languages array from project res folder.
https://github.com/rikkaapps/autoresconfig
android gradle gradle-plugin
Last synced: 4 months ago
JSON representation
A gradle plugin generates resConfig & languages array from project res folder.
- Host: GitHub
- URL: https://github.com/rikkaapps/autoresconfig
- Owner: RikkaApps
- License: mit
- Created: 2022-03-04T16:11:52.000Z (almost 3 years ago)
- Default Branch: master
- Last Pushed: 2022-07-04T06:41:09.000Z (over 2 years ago)
- Last Synced: 2024-10-11T11:21:48.295Z (4 months ago)
- Topics: android, gradle, gradle-plugin
- Language: Java
- Homepage:
- Size: 91.8 KB
- Stars: 32
- Watchers: 6
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# AutoResConfig
For Android application projects that accept user-submitted translations, the number of supported languages may be large and growing. When new languages are added, developers need to manually update `resConfig` (1) and language array xml/class (2). Manual means there could be human error.
(1) `resConfig` limits the final packaged resources. Libraries may carry languages resources which the language is not supported by the application itself. Set `resConfig` could reduce apk size.
(2) If the application has a "choose language" feature, there must be an array of supported languages (could be as an Android resource XML or a Java class).
This plugin collect locales from `values-` folders, set `resConfig`, generate language array xml/class.
## Usage
![gradle-plugin](https://img.shields.io/maven-central/v/dev.rikka.tools.autoresconfig/dev.rikka.tools.autoresconfig.gradle.plugin?label=gradle-plugin)
Replace all the `` below with the version shows here.
1. Add gradle plugin
```groovy
// "old way"
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'dev.rikka.tools.autoresconfig:gradle-plugin:'
}
}
``````groovy
// "new way"
plugins {
id 'dev.rikka.tools.autoresconfig' version ''
}
```2. Use the plugin in Android application module
```groovy
plugins {
id('dev.rikka.tools.autoresconfig')
}3. Config in Android application module
```groovy
autoResConfig {
generateClass = true
generatedClassFullName = "rikka.autoresconfig.Locales"
generateRes = true
generatedResPrefix = null
generatedArrayFirstItem = "SYSTEM"
// Generate Android 13 localeConfig xml
// see https://developer.android.com/about/versions/13/features/app-languages#use-localeconfig
generateLocaleConfig = true
}
```