Advertisement
Guest User

Untitled

a guest
Aug 31st, 2016
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. // iOS
  2.  
  3. public class Localize : ILocalize
  4. {
  5. private static CultureInfo _currentCulture;
  6.  
  7. public CultureInfo GetCurrentCultureInfo()
  8. {
  9. if (_currentCulture != null)
  10. {
  11. return _currentCulture;
  12. }
  13. var netLanguage = "en";
  14. if (NSLocale.PreferredLanguages.Length > 0)
  15. {
  16. var pref = NSLocale.PreferredLanguages[0];
  17.  
  18. if (pref == "pt")
  19. pref = "pt-BR"; // get the correct Brazilian language strings from the PCL RESX
  20. //(note the local iOS folder is still "pt")
  21.  
  22. netLanguage = pref.Replace("_", "-"); // turns es_ES into es-ES
  23. }
  24.  
  25. if (CultureInfo.GetCultures(CultureTypes.AllCultures).Any(x => x.Name == netLanguage))
  26. {
  27. return _currentCulture = new CultureInfo(netLanguage);
  28. }
  29. return _currentCulture = new CultureInfo("en-US");
  30. }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement