GithubHelp home page GithubHelp logo

muxi166 / multilanguages Goto Github PK

View Code? Open in Web Editor NEW

This project forked from qianshui423/multilanguages

1.0 0.0 0.0 7.43 MB

android multi language support (support android O+)

Java 79.09% Groovy 20.91%

multilanguages's Introduction

Android multi-language(support android O+) 中文

support third library multi-language( if there is a corresponding language resource file) ,in version 2.0.

version 2.0

Uses the Transform API to compile instrumentation to achieve attachBaseContext method auto insert of Activity and Service (code is in plugin)

  • support androidx
  • support kotlin
  • Not support Instant Run

Uses

  • multi-language.plugin Download

  • multi-languages Download

  • Import gradle plugin

    classpath 'com.github.jokar:multi-languages.plugin:<latest-version>'
    
  • apply plugin in app buidle.gradle file

    apply plugin: 'multi-languages'
    

    gradle configuration

    multiLanguages {
        //set plugin is enable( default)
        enable = true
        //add forced reorganization of the attachBaseContext method class (If the attachBaseContext method has been overridden in the class, the override will not be overridden by default)
        overwriteClass = ["com.github.jokar.multilanguages.BaseActivity"] 
    }
    
  • import Library

    implementation 'com.github.jokar:multi-languages:<latest-version>'
    
  • application init

    public class MultiLanguagesApp extends Application {
    @Override
    protected void attachBaseContext(Context base) {
        //Save the system language selection when entering the app for the first time.
        LocalManageUtil.saveSystemCurrentLanguage(base);
        super.attachBaseContext(MultiLanguage.setLocal(base));
    }
    
    @Override
    public void onConfigurationChanged(Configuration newConfig) {
        super.onConfigurationChanged(newConfig);
        /**
        The user saves the system selection language when switching languages on the system settings page (in order to select when the system language is used, if it is not saved, it will not be available after switching languages)
        **/
        LocalManageUtil.saveSystemCurrentLanguage(getApplicationContext(), newConfig);
        MultiLanguage.onConfigurationChanged(getApplicationContext());
    }
    
    @Override
    public void onCreate() {
        super.onCreate();
        MultiLanguage.init(new LanguageLocalListener() {
            @Override
            public Locale getSetLanguageLocale(Context context) {
                //return your local settings
                return LocalManageUtil.getSetLanguageLocale(context);
            }
        });
        MultiLanguage.setApplicationLanguage(this);
    }
    }
    

    sample of save multi-language select LocalManageUtil

then is done


sample image

sample-image

multilanguages's People

Contributors

michaeljokar avatar

Stargazers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.