mirror of
https://github.com/BetterAndroid/FlexiLocale.git
synced 2025-09-05 10:45:15 +08:00
Initial commit
This commit is contained in:
105
README.md
Normal file
105
README.md
Normal file
@@ -0,0 +1,105 @@
|
||||
# Flexi Locale
|
||||
|
||||
[](https://github.com/BetterAndroid/FlexiLocale/blob/master/LICENSE)
|
||||
[](https://github.com/BetterAndroid/FlexiLocale/releases)
|
||||
[](https://t.me/BetterAndroid)
|
||||
[](https://t.me/HighCapable_Dev)
|
||||
|
||||
<img src="https://github.com/BetterAndroid/FlexiLocale/blob/master/img-src/icon.png?raw=true" width = "100" height = "100" alt="LOGO"/>
|
||||
|
||||
An easy generation Android i18ns string call Gradle plugin.
|
||||
|
||||
English | [简体中文](https://github.com/BetterAndroid/FlexiLocale/blob/master/README-zh-CN.md)
|
||||
|
||||
## What's this
|
||||
|
||||
This is a Gradle plugin for automatically generating i18ns string calling code functions for Android projects.
|
||||
|
||||
In Android projects, to use i18ns string, you need to define them in `strings.xml` and then call them using `context.getString(R.string.xxx)`, which
|
||||
is very cumbersome and inflexible.
|
||||
|
||||
That's why this project was born.
|
||||
|
||||
With this plugin, you now only need to instantiate the `AppLocale` class generated by the plugin once, and then you can use it anywhere.
|
||||
|
||||
> Traditional Style
|
||||
|
||||
```kotlin
|
||||
val appName = context.getString(R.string.app_name)
|
||||
```
|
||||
|
||||
> Modern Style
|
||||
|
||||
```kotlin
|
||||
val locale by lazy { AppLocale.attach(context) }
|
||||
val appName = locale.appName
|
||||
```
|
||||
|
||||
If you are still using Java, the writing method remains the same.
|
||||
|
||||
```java
|
||||
var locale=AppLocale.attach(context);
|
||||
var appName=locale.getAppName();
|
||||
```
|
||||
|
||||
## Compatibility
|
||||
|
||||
The theory supports not very old Gradle, the recommended version is `7.x.x` and above.
|
||||
|
||||
Android projects containing Kotlin plugins are supported, other types of projects are not supported yet.
|
||||
|
||||
> Build Script Language
|
||||
|
||||
- Kotlin DSL
|
||||
|
||||
It is recommended to use this language as the build script language first, which is also the language currently recommended by Gradle.
|
||||
|
||||
- Groovy DSL
|
||||
|
||||
Some functions may be incompatible, support will be gradually dropped in the future, and some functions may become unavailable.
|
||||
|
||||
## Get Started
|
||||
|
||||
- [Click here](https://github.com/BetterAndroid/FlexiLocale/blob/master/docs/guide.md) to view the documentation
|
||||
|
||||
## Changelog
|
||||
|
||||
- [Click here](https://github.com/BetterAndroid/FlexiLocale/blob/master/docs/changelog.md) to view the historical changelog
|
||||
|
||||
## Promotion
|
||||
|
||||
If you are looking for a Gradle plugin that can automatically manage Gradle project dependencies,
|
||||
you can check out the [SweetDependency](https://github.com/HighCapable/SweetDependency) project.
|
||||
|
||||
If you are looking for a Gradle plugin that can automatically generate properties key-values,
|
||||
you can check out the [SweetProperty](https://github.com/HighCapable/SweetProperty) project.
|
||||
|
||||
This project also uses **SweetDependency** and **SweetProperty**.
|
||||
|
||||
## Star History
|
||||
|
||||

|
||||
|
||||
## License
|
||||
|
||||
- [Apache-2.0](https://www.apache.org/licenses/LICENSE-2.0)
|
||||
|
||||
```
|
||||
Apache License Version 2.0
|
||||
|
||||
Copyright (C) 2019-2023 HighCapable
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
https://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
```
|
||||
|
||||
Copyright © 2019-2023 HighCapable
|
Reference in New Issue
Block a user