Skip to content

Commit

Permalink
Fix #5587
Browse files Browse the repository at this point in the history
  • Loading branch information
dkocher committed Dec 22, 2010
1 parent ee077eb commit b026eaf
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 28 deletions.
5 changes: 2 additions & 3 deletions source/ch/cyberduck/ui/controller/LocaleImpl.cs
Expand Up @@ -41,9 +41,8 @@ private void ReadBundleIntoCache(string bundle)
Log.debug("Caching bundle " + bundle);
Assembly asm = Assembly.GetExecutingAssembly();
// the dots apparently come from the relative path in the msbuild file
Stream stream =
asm.GetManifestResourceStream(string.Format("Ch.Cyberduck..........{0}.lproj.{1}.strings", _language,
bundle));
Stream stream = asm.GetManifestResourceStream(
string.Format("Ch.Cyberduck..........{0}.lproj.{1}.strings", _language, bundle));
if (null == stream)
{
stream =
Expand Down
41 changes: 16 additions & 25 deletions source/ch/cyberduck/ui/controller/UserPreferences.cs
@@ -1,4 +1,4 @@
//
//
// Copyright (c) 2010 Yves Langisch. All rights reserved.
// http://cyberduck.ch/
//
Expand Down Expand Up @@ -155,8 +155,6 @@ public override string getDisplayName(string locale)
{
return "Welsh";
}

//new Locale(...) seems to be very expensive (>100ms on my machine)
CultureInfo cultureInfo = CultureInfo.GetCultureInfo(locale.Replace('_', '-'));
return cultureInfo.TextInfo.ToTitleCase(cultureInfo.NativeName);
}
Expand All @@ -166,28 +164,24 @@ public override List applicationLocales()
Assembly asm = Assembly.GetExecutingAssembly();
string[] names = asm.GetManifestResourceNames();
// the dots apparently come from the relative path in the msbuild file
Regex regex = new Regex("Ch.Cyberduck..........([^\\..]*).lproj.*"); //exclude Sparkle
Regex regex = new Regex("Ch.Cyberduck\\.\\.\\.\\.\\.\\.\\.\\.\\.\\.([^\\..]*).lproj\\.Localizable\\.strings");
List<string> distinctNames = new List<string>();
foreach (var name in names)
{
Match match = regex.Match(name);
if (match.Groups.Count > 1)
{
string cand = match.Groups[1].Value.Replace('_', '-');
if (!distinctNames.Contains(cand))
{
if (("ja".Equals(cand) ||
"ko".Equals(cand) ||
"ka".Equals(cand) ||
"zh-CN".Equals(cand) ||
"zh-TW".Equals(cand)) && !HasEastAsianFontSupport())
{
continue;
}
distinctNames.Add(cand);
}
distinctNames.Add(match.Groups[1].Value);
}
}
if (!HasEastAsianFontSupport())
{
distinctNames.Remove("ja");
distinctNames.Remove("ko");
distinctNames.Remove("ka");
distinctNames.Remove("zh_CN");
distinctNames.Remove("zh_TW");
}
return Utils.ConvertToJavaList(distinctNames);
}

Expand Down Expand Up @@ -217,14 +211,12 @@ public override void save()

public override List systemLocales()
{
List sysLocales = new ArrayList();

List locales = new ArrayList();
//add current UI culture
sysLocales.add(CultureInfo.CurrentUICulture.Name);
locales.add(CultureInfo.CurrentUICulture.Name);
//add current system culture
sysLocales.add(Application.CurrentCulture.Name);

return sysLocales;
locales.add(Application.CurrentCulture.Name);
return locales;
}

protected override void load()
Expand Down Expand Up @@ -326,11 +318,10 @@ public string GetDefaultLanguage()
{
List sysLocales = systemLocales();
List appLocales = applicationLocales();

for (int i = 0; i < sysLocales.size(); i++)
{
string s = (string) sysLocales.get(i);
string match = TryToMatchLocale(s, appLocales);
string match = TryToMatchLocale(s.Replace('-', '_'), appLocales);
if (null != match)
{
Log.debug(String.Format("Default locale is '{0}' for system locale '{1}'", match, s));
Expand Down

0 comments on commit b026eaf

Please sign in to comment.