lingver icon indicating copy to clipboard operation
lingver copied to clipboard

Part of the UI is not loading the correct language

Open nuwanchamara opened this issue 5 years ago • 12 comments

I have a BaseActivity which Extends AppCompatActivity.

public class BaseActivity extends AppCompatActivity {

    private final String TAG = "BaseActivity";

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
        Log.e(TAG, "LANGUAGE : " + C.CurrentLanguage);
    }


    @Override
    public void applyOverrideConfiguration(Configuration overrideConfiguration) {
        if (overrideConfiguration != null) {
            int uiMode = overrideConfiguration.uiMode;
            overrideConfiguration.setTo(getBaseContext().getResources().getConfiguration());
            overrideConfiguration.uiMode = uiMode;
        }
        super.applyOverrideConfiguration(overrideConfiguration);
    }
}

After Changing the Language it look like this.

71251609-d405f880-2348-11ea-8c0f-c02ea3c09d1e

I have checked for missing translations. But all the strings are there . But not loading some of the strings. How to solve this issue

nuwanchamara avatar Dec 20 '19 12:12 nuwanchamara

I have same problem

TikTak123 avatar Dec 21 '19 15:12 TikTak123

Guys, could anyone create a small sample project that can reproduce the issue? since I can't replicate it on my side. I've been using this approach (not the library) for years and have never faced this issue.

YarikSOffice avatar Dec 23 '19 19:12 YarikSOffice

I made this project using fragments. https://github.com/TikTak123/LanguageFragmentExample

I made this project using Conductor. https://github.com/TikTak123/LanguageConductorExample

Both have the same problem. Here is the video that plays the bug. https://drive.google.com/file/d/1xU90veGEjSpQb-AEg9cFkk7Bhxnt6Nwn/view?usp=sharing

Steps to reproduce the bug:

  1. Change the language to Ukrainian.
  2. Open another window.
  3. Go back.

TikTak123 avatar Dec 25 '19 08:12 TikTak123

@TikTak123 thanks for the sample project! Finally, I can reproduce it.

Looks like a web view resets the locale to the device default. There is another issue submitted today reporting the same behavior.

I'll investigate that soon and check what I can do. Stay tuned.

YarikSOffice avatar Dec 25 '19 12:12 YarikSOffice

@nuwanchamara Have you solved the problem with changing the language? I also have this problem even without WebView. This bug works after changing the language and it does not always work, and not everywhere and not on all devices. I can’t reproduce it in the sample project. Other than that, I'm not sure if this is the case with the Lingver library, since I use the Conductor library instead of fragments. Can you write a sample project where this bug is reproduced in your case?

As my case, I still have not found the answer. Here are my other language change questions: https://github.com/YarikSOffice/lingver/issues/11 https://github.com/bluelinelabs/Conductor/issues/579 https://github.com/bluelinelabs/Conductor/issues/580

TikTak123 avatar Dec 26 '19 11:12 TikTak123

Hi, I was also having this issue and i fixed it by this code. I don`t know if this is good way of doing it or not but it worked for me. override fun onDestroy() { super.onDestroy() context?.let { Lingver.getInstance().setLocale(it, getLocale()) } // get actual selected locale here webView.destroy() }

khushwaqt avatar Jan 07 '20 12:01 khushwaqt

There is a critical bug in version 1.2.0. According to my tests, it happens while setting a locale with a country qualifier ( e.g. en_US) on Android API 24 and above.

Kindly update the library and let me know if it's fixed for you.

Also, the latest version addresses the well-known bug with WebView related to locales. Kindly check the documentation for more info as well as the sample project for an example of implementation.

YarikSOffice avatar Jan 20 '20 12:01 YarikSOffice

This is didn't help me, but in my app I fixed this issue like this:

    @Override
    protected void onContextAvailable(@NonNull Context context) {
        super.onContextAvailable(context);
        Lingver.getInstance().setLocale(context, Lingver.getInstance().getLocale());
    }

Every time when Controller created it calls onContextAvailable method where I set locale again.

TikTak123 avatar Feb 06 '20 07:02 TikTak123

@YarikSOffice I have the same problem and after update the library to latest version (1.2.1), My problem was not solved. I use this lib in the android project.

what can i do?

rexi1r avatar Mar 30 '20 21:03 rexi1r

@rexi1r could you describe your issue in more details? a sample project reproducing the issue will be highly appreciated since I've been not able to identify it for a long time already.

YarikSOffice avatar Mar 31 '20 14:03 YarikSOffice

@YarikSOffice yeh, This problem often occurs at the first application opening. you can see the tab's name is correct language but the content of tab that is inside a fragment, it's not correct, I will try to create a sample application but, our problem occurs on our situation, so it's better to solve this problem for all. Screens

rexi1r avatar Mar 31 '20 14:03 rexi1r

@rexi1r a sample project will significantly help fixing this issue for everyone. Thanks in advance!

YarikSOffice avatar Mar 31 '20 14:03 YarikSOffice