mirror of
https://github.com/crskycode/GARbro.git
synced 2024-12-23 19:34:15 +08:00
improved plural localization.
This commit is contained in:
parent
045988301b
commit
d15addd44f
@ -208,26 +208,24 @@ namespace GARbro.GUI
|
||||
extractProgressDialog.Description = file_list.First().Name;
|
||||
extractProgressDialog.ProgressBarStyle = ProgressBarStyle.MarqueeProgressBar;
|
||||
}
|
||||
int extract_count = 0;
|
||||
extractProgressDialog.DoWork += (s, e) =>
|
||||
{
|
||||
try
|
||||
{
|
||||
int total = file_list.Count();
|
||||
int i = 0;
|
||||
foreach (var entry in file_list)
|
||||
{
|
||||
if (extractProgressDialog.CancellationPending)
|
||||
break;
|
||||
if (total > 1)
|
||||
extractProgressDialog.ReportProgress (i*100/total, null, entry.Name);
|
||||
extractProgressDialog.ReportProgress (extract_count*100/total, null, entry.Name);
|
||||
if (null != image_format && entry.Type == "image")
|
||||
ExtractImage (arc, entry, image_format);
|
||||
else
|
||||
arc.Extract (entry);
|
||||
++i;
|
||||
++extract_count;
|
||||
}
|
||||
SetStatusText (string.Format (guiStrings.MsgExtractCompletePlural, i,
|
||||
Localization.Plural (i, "file")));
|
||||
}
|
||||
catch (Exception X)
|
||||
{
|
||||
@ -241,6 +239,7 @@ namespace GARbro.GUI
|
||||
arc.Dispose();
|
||||
Dispatcher.Invoke (RefreshView);
|
||||
}
|
||||
SetStatusText (Localization.Format ("MsgExtractedFiles", extract_count));
|
||||
};
|
||||
extractProgressDialog.ShowDialog (this);
|
||||
}
|
||||
|
33
Strings/guiStrings.Designer.cs
generated
33
Strings/guiStrings.Designer.cs
generated
@ -303,24 +303,6 @@ namespace GARbro.GUI.Strings {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to file.
|
||||
/// </summary>
|
||||
public static string LPfile1 {
|
||||
get {
|
||||
return ResourceManager.GetString("LPfile1", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to files.
|
||||
/// </summary>
|
||||
public static string LPfile2 {
|
||||
get {
|
||||
return ResourceManager.GetString("LPfile2", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to About Game Resource browser.
|
||||
/// </summary>
|
||||
@ -448,11 +430,20 @@ namespace GARbro.GUI.Strings {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Extracted {0} {1}.
|
||||
/// Looks up a localized string similar to Extracted {0} file.
|
||||
/// </summary>
|
||||
public static string MsgExtractCompletePlural {
|
||||
public static string MsgExtractedFiles1 {
|
||||
get {
|
||||
return ResourceManager.GetString("MsgExtractCompletePlural", resourceCulture);
|
||||
return ResourceManager.GetString("MsgExtractedFiles1", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Extracted {0} files.
|
||||
/// </summary>
|
||||
public static string MsgExtractedFiles2 {
|
||||
get {
|
||||
return ResourceManager.GetString("MsgExtractedFiles2", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -198,12 +198,6 @@
|
||||
<data name="LabelExtractFileTo" xml:space="preserve">
|
||||
<value>Extract {0} to</value>
|
||||
</data>
|
||||
<data name="LPfile1" xml:space="preserve">
|
||||
<value>file</value>
|
||||
</data>
|
||||
<data name="LPfile2" xml:space="preserve">
|
||||
<value>files</value>
|
||||
</data>
|
||||
<data name="MenuAbout" xml:space="preserve">
|
||||
<value>About Game Resource browser</value>
|
||||
</data>
|
||||
@ -225,8 +219,8 @@
|
||||
<data name="MsgExtractComplete" xml:space="preserve">
|
||||
<value>Extracted {0} into {1}</value>
|
||||
</data>
|
||||
<data name="MsgExtractCompletePlural" xml:space="preserve">
|
||||
<value>Extracted {0} {1}</value>
|
||||
<data name="MsgExtractedFiles1" xml:space="preserve">
|
||||
<value>Extracted {0} file</value>
|
||||
</data>
|
||||
<data name="MsgExtractingArchive" xml:space="preserve">
|
||||
<value>Extracting files from {0}</value>
|
||||
@ -348,4 +342,7 @@ Overwrite?</value>
|
||||
<data name="MenuHelp" xml:space="preserve">
|
||||
<value>_Help</value>
|
||||
</data>
|
||||
<data name="MsgExtractedFiles2" xml:space="preserve">
|
||||
<value>Extracted {0} files</value>
|
||||
</data>
|
||||
</root>
|
@ -195,15 +195,6 @@
|
||||
<data name="LabelExtractFileTo" xml:space="preserve">
|
||||
<value>Извлечь {0} в</value>
|
||||
</data>
|
||||
<data name="LPfile1" xml:space="preserve">
|
||||
<value>файл</value>
|
||||
</data>
|
||||
<data name="LPfile2" xml:space="preserve">
|
||||
<value>файла</value>
|
||||
</data>
|
||||
<data name="LPfile3" xml:space="preserve">
|
||||
<value>файлов</value>
|
||||
</data>
|
||||
<data name="MenuAbout" xml:space="preserve">
|
||||
<value>О программе</value>
|
||||
</data>
|
||||
@ -225,9 +216,6 @@
|
||||
<data name="MsgExtractComplete" xml:space="preserve">
|
||||
<value>{0} извлечён в {1}</value>
|
||||
</data>
|
||||
<data name="MsgExtractCompletePlural" xml:space="preserve">
|
||||
<value>Извлечено {0} {1}</value>
|
||||
</data>
|
||||
<data name="MsgExtractingArchive" xml:space="preserve">
|
||||
<value>Извлекаются файлы из {0}</value>
|
||||
</data>
|
||||
@ -360,4 +348,13 @@
|
||||
<data name="MenuHelp" xml:space="preserve">
|
||||
<value>_Справка</value>
|
||||
</data>
|
||||
<data name="MsgExtractedFiles1" xml:space="preserve">
|
||||
<value>Извлечён {0} файл</value>
|
||||
</data>
|
||||
<data name="MsgExtractedFiles2" xml:space="preserve">
|
||||
<value>Извлечено {0} файла</value>
|
||||
</data>
|
||||
<data name="MsgExtractedFiles3" xml:space="preserve">
|
||||
<value>Извлечено {0} файлов</value>
|
||||
</data>
|
||||
</root>
|
20
Utility.cs
20
Utility.cs
@ -109,7 +109,7 @@ namespace GARbro.GUI
|
||||
|
||||
public static class Localization
|
||||
{
|
||||
public static string Plural (int n, string en_singular)
|
||||
public static string Plural (int n, string msg_id)
|
||||
{
|
||||
string suffix;
|
||||
if (CultureInfo.CurrentUICulture.Name == "ru-RU")
|
||||
@ -122,15 +122,25 @@ namespace GARbro.GUI
|
||||
}
|
||||
try
|
||||
{
|
||||
var res = guiStrings.ResourceManager.GetString ("LP"+en_singular+suffix);
|
||||
return res ?? en_singular;
|
||||
var res = guiStrings.ResourceManager.GetString (msg_id+suffix);
|
||||
if (null == res && suffix != "1")
|
||||
res = guiStrings.ResourceManager.GetString (msg_id+"1");
|
||||
if (null == res)
|
||||
Trace.WriteLine (string.Format ("Missing string resource for '{0}' token", msg_id+suffix));
|
||||
return res ?? msg_id;
|
||||
}
|
||||
catch
|
||||
catch (Exception X)
|
||||
{
|
||||
return en_singular;
|
||||
Trace.WriteLine (X.Message, "Localization.Plural");
|
||||
return msg_id;
|
||||
}
|
||||
}
|
||||
|
||||
public static string Format (string msg_id, int n)
|
||||
{
|
||||
return string.Format (Plural (n, msg_id), n);
|
||||
}
|
||||
|
||||
// Localization.Format ("{0:file:files} copied", count);
|
||||
// public static string Format (string format, params object[] args);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user