Advertisement
minafaw3

old_LanguageUtil

Mar 30th, 2017
343
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. using System;
  2. using Android.Content;
  3. using Android.Content.Res;
  4. using Android.Util;
  5. using Java.Util;
  6.  
  7. namespace ReadyApps.Xamarin.Framework.Droid
  8. {
  9. public class LanguageUtil
  10. {
  11. public static void ChangeLanguageType(Context context, Locale localelanguage)
  12. {
  13. var resources = context.Resources;
  14.  
  15. DisplayMetrics dm = resources.DisplayMetrics;
  16. Configuration config = resources.Configuration;
  17. if (VersionUtils.isAfter24())
  18. {
  19. config.SetLocale(localelanguage);
  20. }
  21. else
  22. {
  23. config.Locale = localelanguage;
  24. resources.UpdateConfiguration(config, dm);
  25. }
  26. }
  27.  
  28. public static Locale getLanguageType(Context context)
  29. {
  30. var resources = context.Resources;
  31.  
  32. Configuration config = resources.Configuration;
  33. if (VersionUtils.isAfter24())
  34. {
  35. return config.Locales.Get(0);
  36. }
  37. else
  38. {
  39. return config.Locale;
  40. }
  41. }
  42. }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement