kopia lustrzana https://github.com/njcrawford/EmbroideryReader
Rename translation files to language codes
Zip files don't handle Unicode characters, so store the translation/language name in the ini file, instead of the name.Branch_2.1.x
rodzic
85a022bd10
commit
c570b3121d
|
@ -51,10 +51,10 @@
|
|||
</Component>
|
||||
<Directory Id="_A6E55FAE6BDA433A9AA014FC66904077" Name="translations">
|
||||
<Component Id="TranslationInis" Guid="29712DD3-062D-4767-AB4F-8F390FF57BED">
|
||||
<File Id="ENGLISH__EN_US_.INI" Name="English (EN-US).ini" Source="..\translations\English (EN-US).ini" DiskId="1" />
|
||||
<File Id="ITALIANO__IT_.INI" Name="Italiano (IT).ini" Source="..\translations\Italiano (IT).ini" DiskId="1" />
|
||||
<File Id="_________ZH_HANS_.INI" Name="中文 (简体) (zh-hans).ini" Source="..\translations\中文 (简体) (zh-hans).ini" DiskId="1" />
|
||||
<File Id="________ZH_HANT_.INI" Name="中文(繁体) (zh-hant).ini" Source="..\translations\中文(繁体) (zh-hant).ini" DiskId="1" />
|
||||
<File Id="EN_US.INI" Name="EN-US.ini" Source="..\translations\EN-US.ini" DiskId="1" />
|
||||
<File Id="IT.INI" Name="IT.ini" Source="..\translations\IT.ini" DiskId="1" />
|
||||
<File Id="ZH_HANS.INI" Name="zh-hans.ini" Source="..\translations\zh-hans.ini" DiskId="1" />
|
||||
<File Id="ZH_HANT.INI" Name="zh-hant.ini" Source="..\translations\zh-hant.ini" DiskId="1" />
|
||||
</Component>
|
||||
</Directory>
|
||||
<Directory Id="DesktopFolder" SourceName="User's Desktop" />
|
||||
|
|
|
@ -34,10 +34,12 @@ namespace embroideryReader
|
|||
{
|
||||
private const string TRANSLATIONS_FOLDER = "translations";
|
||||
private const string TRANSLATION_FILE_EXT = ".ini";
|
||||
private const string DEFAULT_TRANSLATION_NAME = "English (EN-US)";
|
||||
private const string DEFAULT_TRANSLATION_NAME = "EN-US";
|
||||
|
||||
// String IDs
|
||||
public enum StringID {
|
||||
TRANSLATION_DISPLAY_NAME,
|
||||
|
||||
UNSUPPORTED_FORMAT,
|
||||
COLOR_WARNING,
|
||||
ERROR_FILE,
|
||||
|
@ -117,16 +119,19 @@ namespace embroideryReader
|
|||
}
|
||||
|
||||
// Returns the names of available translations
|
||||
// Names are just the file name without the extension
|
||||
public List<String> GetAvailableTranslations()
|
||||
// The first value of each tubple is the display name, the second value
|
||||
// is the file name that must be passed to the open function.
|
||||
public List<Tuple<String, String>> GetAvailableTranslations()
|
||||
{
|
||||
List<String> retval = new List<string>();
|
||||
List<Tuple<String, String>> retval = new List<Tuple<String, String>>();
|
||||
foreach (String file in System.IO.Directory.EnumerateFiles(
|
||||
System.IO.Path.Combine(Environment.CurrentDirectory, TRANSLATIONS_FOLDER),
|
||||
"*" + TRANSLATION_FILE_EXT,
|
||||
System.IO.SearchOption.TopDirectoryOnly))
|
||||
{
|
||||
retval.Add(System.IO.Path.GetFileNameWithoutExtension(file));
|
||||
IniFile tempFile = new IniFile(file);
|
||||
|
||||
retval.Add(new Tuple<String, String>(tempFile.getValue(StringID.TRANSLATION_DISPLAY_NAME.ToString(), ""), System.IO.Path.GetFileNameWithoutExtension(file)));
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
@ -135,8 +140,16 @@ namespace embroideryReader
|
|||
// Names are just the file name without the extension
|
||||
public void Load(String translationName)
|
||||
{
|
||||
translationFile = new IniFile(System.IO.Path.Combine(TRANSLATIONS_FOLDER, translationName + TRANSLATION_FILE_EXT));
|
||||
defaultFile = new IniFile(System.IO.Path.Combine(TRANSLATIONS_FOLDER, DEFAULT_TRANSLATION_NAME + TRANSLATION_FILE_EXT));
|
||||
String translationPath = System.IO.Path.Combine(TRANSLATIONS_FOLDER, translationName + TRANSLATION_FILE_EXT);
|
||||
if (System.IO.File.Exists(translationPath))
|
||||
{
|
||||
translationFile = new IniFile(translationPath);
|
||||
}
|
||||
else
|
||||
{
|
||||
translationFile = defaultFile;
|
||||
}
|
||||
}
|
||||
|
||||
// Returns the translated string, or a string representation of the
|
||||
|
@ -144,16 +157,16 @@ namespace embroideryReader
|
|||
public String GetTranslatedString(StringID sid)
|
||||
{
|
||||
string retval;
|
||||
retval = translationFile.getValue(sid.ToString(), (String)null);
|
||||
retval = translationFile.getValue(sid.ToString(), "");
|
||||
|
||||
// Check the default translation if string is not found in the loaded translation
|
||||
if (retval == null)
|
||||
if (String.IsNullOrEmpty(retval))
|
||||
{
|
||||
retval = defaultFile.getValue(sid.ToString(), (String)null);
|
||||
retval = defaultFile.getValue(sid.ToString(), "");
|
||||
}
|
||||
|
||||
// If it's not found in the default, return a placeholder string
|
||||
if (retval == null)
|
||||
if (String.IsNullOrEmpty(retval))
|
||||
{
|
||||
retval = "%" + sid.ToString() + "%";
|
||||
}
|
||||
|
|
|
@ -38,6 +38,9 @@ namespace embroideryReader
|
|||
this.txtThreadThickness = new System.Windows.Forms.TextBox();
|
||||
this.lblPixelThick = new System.Windows.Forms.Label();
|
||||
this.grpBackground = new System.Windows.Forms.GroupBox();
|
||||
this.txtGridSize = new System.Windows.Forms.TextBox();
|
||||
this.lblGridSizePixels = new System.Windows.Forms.Label();
|
||||
this.lblGridSize = new System.Windows.Forms.Label();
|
||||
this.btnResetGridColor = new System.Windows.Forms.Button();
|
||||
this.btnGridColor = new System.Windows.Forms.Button();
|
||||
this.pnlBackground = new System.Windows.Forms.Panel();
|
||||
|
@ -51,9 +54,6 @@ namespace embroideryReader
|
|||
this.cmbLanguage = new System.Windows.Forms.ComboBox();
|
||||
this.grpLanguage = new System.Windows.Forms.GroupBox();
|
||||
this.lblIncompleteTranslation = new System.Windows.Forms.Label();
|
||||
this.lblGridSize = new System.Windows.Forms.Label();
|
||||
this.lblGridSizePixels = new System.Windows.Forms.Label();
|
||||
this.txtGridSize = new System.Windows.Forms.TextBox();
|
||||
this.grpBackground.SuspendLayout();
|
||||
this.pnlBackground.SuspendLayout();
|
||||
this.grpStitch.SuspendLayout();
|
||||
|
@ -145,6 +145,32 @@ namespace embroideryReader
|
|||
this.grpBackground.TabStop = false;
|
||||
this.grpBackground.Text = "Background";
|
||||
//
|
||||
// txtGridSize
|
||||
//
|
||||
this.txtGridSize.Location = new System.Drawing.Point(64, 96);
|
||||
this.txtGridSize.Name = "txtGridSize";
|
||||
this.txtGridSize.Size = new System.Drawing.Size(32, 20);
|
||||
this.txtGridSize.TabIndex = 18;
|
||||
this.txtGridSize.TextChanged += new System.EventHandler(this.txtGridSize_TextChanged);
|
||||
//
|
||||
// lblGridSizePixels
|
||||
//
|
||||
this.lblGridSizePixels.AutoSize = true;
|
||||
this.lblGridSizePixels.Location = new System.Drawing.Point(102, 99);
|
||||
this.lblGridSizePixels.Name = "lblGridSizePixels";
|
||||
this.lblGridSizePixels.Size = new System.Drawing.Size(33, 13);
|
||||
this.lblGridSizePixels.TabIndex = 17;
|
||||
this.lblGridSizePixels.Text = "pixels";
|
||||
//
|
||||
// lblGridSize
|
||||
//
|
||||
this.lblGridSize.AutoSize = true;
|
||||
this.lblGridSize.Location = new System.Drawing.Point(6, 99);
|
||||
this.lblGridSize.Name = "lblGridSize";
|
||||
this.lblGridSize.Size = new System.Drawing.Size(52, 13);
|
||||
this.lblGridSize.TabIndex = 16;
|
||||
this.lblGridSize.Text = "Grid Size:";
|
||||
//
|
||||
// btnResetGridColor
|
||||
//
|
||||
this.btnResetGridColor.Location = new System.Drawing.Point(171, 100);
|
||||
|
@ -278,32 +304,6 @@ namespace embroideryReader
|
|||
this.lblIncompleteTranslation.Text = "Translation is incomplete";
|
||||
this.lblIncompleteTranslation.Visible = false;
|
||||
//
|
||||
// lblGridSize
|
||||
//
|
||||
this.lblGridSize.AutoSize = true;
|
||||
this.lblGridSize.Location = new System.Drawing.Point(6, 99);
|
||||
this.lblGridSize.Name = "lblGridSize";
|
||||
this.lblGridSize.Size = new System.Drawing.Size(52, 13);
|
||||
this.lblGridSize.TabIndex = 16;
|
||||
this.lblGridSize.Text = "Grid Size:";
|
||||
//
|
||||
// lblGridSizePixels
|
||||
//
|
||||
this.lblGridSizePixels.AutoSize = true;
|
||||
this.lblGridSizePixels.Location = new System.Drawing.Point(102, 99);
|
||||
this.lblGridSizePixels.Name = "lblGridSizePixels";
|
||||
this.lblGridSizePixels.Size = new System.Drawing.Size(33, 13);
|
||||
this.lblGridSizePixels.TabIndex = 17;
|
||||
this.lblGridSizePixels.Text = "pixels";
|
||||
//
|
||||
// txtGridSize
|
||||
//
|
||||
this.txtGridSize.Location = new System.Drawing.Point(64, 96);
|
||||
this.txtGridSize.Name = "txtGridSize";
|
||||
this.txtGridSize.Size = new System.Drawing.Size(32, 20);
|
||||
this.txtGridSize.TabIndex = 18;
|
||||
this.txtGridSize.TextChanged += new System.EventHandler(this.txtGridSize_TextChanged);
|
||||
//
|
||||
// frmSettingsDialog
|
||||
//
|
||||
this.AcceptButton = this.btnOK;
|
||||
|
@ -323,6 +323,7 @@ namespace embroideryReader
|
|||
this.Name = "frmSettingsDialog";
|
||||
this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide;
|
||||
this.Text = "Embroidery Reader Settings";
|
||||
this.Load += new System.EventHandler(this.frmSettingsDialog_Load);
|
||||
this.grpBackground.ResumeLayout(false);
|
||||
this.grpBackground.PerformLayout();
|
||||
this.pnlBackground.ResumeLayout(false);
|
||||
|
|
|
@ -37,6 +37,7 @@ namespace embroideryReader
|
|||
{
|
||||
private EmbroideryReaderSettings settings;
|
||||
private Translation translation;
|
||||
private List<Tuple<String, String>> availableTranslations = new List<Tuple<string,string>>();
|
||||
|
||||
public EmbroideryReaderSettings settingsToModify
|
||||
{
|
||||
|
@ -114,7 +115,7 @@ namespace embroideryReader
|
|||
settings.transparencyGridSize = gridSize;
|
||||
}
|
||||
|
||||
settings.translation = cmbLanguage.SelectedItem.ToString();
|
||||
settings.translation = availableTranslations[cmbLanguage.SelectedIndex].Item2;
|
||||
}
|
||||
|
||||
public Translation setTranslation
|
||||
|
@ -123,13 +124,14 @@ namespace embroideryReader
|
|||
{
|
||||
translation = value;
|
||||
loadTranslatedStrings();
|
||||
foreach (String s in translation.GetAvailableTranslations())
|
||||
availableTranslations = translation.GetAvailableTranslations();
|
||||
foreach (Tuple<String, String> names in availableTranslations)
|
||||
{
|
||||
cmbLanguage.Items.Add(s);
|
||||
}
|
||||
if (cmbLanguage.Items.Count > 0)
|
||||
{
|
||||
cmbLanguage.SelectedItem = settings.translation;
|
||||
cmbLanguage.Items.Add(names.Item1 + " (" + names.Item2 + ")");
|
||||
if(names.Item2 == settings.translation)
|
||||
{
|
||||
cmbLanguage.SelectedIndex = cmbLanguage.Items.Count - 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -166,7 +168,7 @@ namespace embroideryReader
|
|||
|
||||
private void cmbLanguage_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
translation.Load(cmbLanguage.SelectedItem.ToString());
|
||||
translation.Load(availableTranslations[cmbLanguage.SelectedIndex].Item2);
|
||||
lblIncompleteTranslation.Visible = !translation.IsComplete();
|
||||
loadTranslatedStrings();
|
||||
}
|
||||
|
@ -236,5 +238,10 @@ namespace embroideryReader
|
|||
pnlBackground.Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
private void frmSettingsDialog_Load(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
# If you make a new translation, please contact me! I'd love to
|
||||
# include your translation with Embroidery Reader.
|
||||
# The best way to contact me is through http://www.njcrawford.com/contact/.
|
||||
TRANSLATION_DISPLAY_NAME=English
|
||||
UNSUPPORTED_FORMAT=The format of this file is not completely supported
|
||||
COLOR_WARNING=Colors shown for this design may be inaccurate
|
||||
ERROR_FILE=An error occurred while reading the file:
|
|
@ -3,6 +3,7 @@
|
|||
# If you make a new translation, please contact me! I'd love to
|
||||
# include your translation with Embroidery Reader.
|
||||
# The best way to contact me is through http://www.njcrawford.com/contact/.
|
||||
TRANSLATION_DISPLAY_NAME=Italiano
|
||||
UNSUPPORTED_FORMAT=Il formato di questo file non è pienamente supportato
|
||||
COLOR_WARNING=I colori mostrati per questo progetto potrebbero non essere precisi
|
||||
ERROR_FILE=Si è verificato un errore durante la lettura del file:
|
Plik binarny nie jest wyświetlany.
|
@ -3,6 +3,7 @@
|
|||
# If you make a new translation, please contact me! I'd love to
|
||||
# include your translation with Embroidery Reader.
|
||||
# The best way to contact me is through http://www.njcrawford.com/contact/.
|
||||
TRANSLATION_DISPLAY_NAME=中文 (简体)
|
||||
UNSUPPORTED_FORMAT=不支持的文件格式
|
||||
COLOR_WARNING=这个花样显示的颜色可能不正确
|
||||
ERROR_FILE=读文件错误:
|
|
@ -3,6 +3,7 @@
|
|||
# If you make a new translation, please contact me! I'd love to
|
||||
# include your translation with Embroidery Reader.
|
||||
# The best way to contact me is through http://www.njcrawford.com/contact/.
|
||||
TRANSLATION_DISPLAY_NAME=中文(繁体)
|
||||
UNSUPPORTED_FORMAT=不支持的文件格式
|
||||
COLOR_WARNING=這個花樣顯示的顏色可能不正確
|
||||
ERROR_FILE=讀文件錯誤:
|
Ładowanie…
Reference in New Issue