Reword is a library to update the texts of views when the apps texts have changed due to a language change or an update of the apps string resources with a lib like Restring or AppLocale.
// Intercept view inflation
implementation 'dev.b3nedikt.viewpump:viewpump:4.0.10'
// Allows to update the text of views at runtime without recreating the activity
implementation 'dev.b3nedikt.reword:reword:4.0.4'
Initialize Reword in your Application class:
ViewPump.init(RewordInterceptor.INSTANCE);
For example update all views in the current activity:
Reword.setLocale(Locales.FRENCH);
// The layout containing the views you want to localize
final View rootView = getWindow().getDecorView().findViewById(android.R.id.content);
Reword.reword(rootView);
This library supports many common android views out of the box. If you need to support custom views only used by your app, you can however do it like this:
Reword.addViewTransformer(new YourCustomViewTransformer())
See the TextViewViewTransformer as an example how a ViewTransformer implementation should look like.
This library takes some inspiration from the library "restring" originally developed by Hamid Gharehdaghi, as well as the library "Philology" by JcMinarro.
Copyright 2019-present Reword Contributors.
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
http://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.