Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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.

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
}
```