Added new subtitle format + Basque translation (thx Xabier Aramendi)

git-svn-id: https://subtitleedit.googlecode.com/svn/trunk@424 99eadd0c-20b8-1223-b5c4-2a2b2df33de2
This commit is contained in:
niksedk 2011-05-11 05:11:52 +00:00
parent d082d7454a
commit b689e4a8ee
15 changed files with 1463 additions and 55 deletions

View File

@ -43,9 +43,16 @@ namespace Nikse.SubtitleEdit.Forms
} }
private void RichTextBoxAbout1LinkClicked(object sender, LinkClickedEventArgs e) private void RichTextBoxAbout1LinkClicked(object sender, LinkClickedEventArgs e)
{
try
{ {
Process.Start(e.LinkText); Process.Start(e.LinkText);
} }
catch
{
MessageBox.Show("Unable to start link: " + e.LinkText, Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void buttonDonate_Click(object sender, EventArgs e) private void buttonDonate_Click(object sender, EventArgs e)
{ {

View File

@ -691,6 +691,7 @@
this.toolStripComboBoxFrameRate.FlatStyle = System.Windows.Forms.FlatStyle.Standard; this.toolStripComboBoxFrameRate.FlatStyle = System.Windows.Forms.FlatStyle.Standard;
this.toolStripComboBoxFrameRate.Name = "toolStripComboBoxFrameRate"; this.toolStripComboBoxFrameRate.Name = "toolStripComboBoxFrameRate";
this.toolStripComboBoxFrameRate.Size = new System.Drawing.Size(100, 40); this.toolStripComboBoxFrameRate.Size = new System.Drawing.Size(100, 40);
this.toolStripComboBoxFrameRate.TextChanged += new System.EventHandler(this.toolStripComboBoxFrameRate_TextChanged);
// //
// toolStripButtonGetFrameRate // toolStripButtonGetFrameRate
// //

View File

@ -1803,6 +1803,7 @@ namespace Nikse.SubtitleEdit.Forms
_oldSubtitleFormat = null; _oldSubtitleFormat = null;
labelSingleLine.Text = string.Empty; labelSingleLine.Text = string.Empty;
RemoveAlternate(true); RemoveAlternate(true);
toolStripComboBoxFrameRate.Text = Configuration.Settings.General.DefaultFrameRate.ToString();
comboBoxEncoding.Items[0] = "ANSI - " + Encoding.Default.CodePage.ToString(); comboBoxEncoding.Items[0] = "ANSI - " + Encoding.Default.CodePage.ToString();
if (Configuration.Settings.General.DefaultEncoding == "ANSI") if (Configuration.Settings.General.DefaultEncoding == "ANSI")
@ -7963,7 +7964,7 @@ namespace Nikse.SubtitleEdit.Forms
else else
SubtitleListview1.Focus(); SubtitleListview1.Focus();
if (Configuration.Settings.General.Undocked) if (Configuration.Settings.General.Undocked && Configuration.Settings.General.StartRememberPositionAndSize)
{ {
SetPositionFromXYString(Configuration.Settings.General.UndockedVideoPosition, "VideoPlayerUnDocked"); SetPositionFromXYString(Configuration.Settings.General.UndockedVideoPosition, "VideoPlayerUnDocked");
SetPositionFromXYString(Configuration.Settings.General.UndockedWaveformPosition, "WaveFormUnDocked"); SetPositionFromXYString(Configuration.Settings.General.UndockedWaveformPosition, "WaveFormUnDocked");
@ -9953,5 +9954,10 @@ namespace Nikse.SubtitleEdit.Forms
} }
} }
private void toolStripComboBoxFrameRate_TextChanged(object sender, EventArgs e)
{
Configuration.Settings.General.CurrentFrameRate = CurrentFrameRate;
}
} }
} }

View File

@ -683,46 +683,46 @@
<value> <value>
AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w
LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0 LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0
ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAAD2 ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAAD0
CAAAAk1TRnQBSQFMAgEB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AABHAHCBAgCeAHsAZkCCAJ4AewB8wEcAcIECAJ4AewBmQIIAngB7AF1IAABmAEcAZIB7QHsAQgBmAHs
AewB8AHvAewBCAGYAewB8wEAAZgBHAGSAe0B7AEIAZgB7AHwAe8B7AEIAZgB7AJ1JAAB7QEIAewB8wIA AfAB7wHsAQgBmAHsAfMBAAGYARwBkgHtAewBCAGYAewB8AHvAewBCAGYAewCdSQAAe0BCAHsAfMCAAHt
Ae0BCAHsAfMCAAR1Ae0BCAHsA3UB7QEIAewDdSQAAZIB7AHzAwABkgHsAfMDAAR1AZIB7AR1AZIB7AR1 AQgB7AHzAgAEdQHtAQgB7AN1Ae0BCAHsA3UkAAGSAewB8wMAAZIB7AHzAwAEdQGSAewEdQGSAewEdSQA
JAABHAH0BAABHAH0BAAEdQEcBXUBHAV1MAAQdTAAEHUgAAFCAU0BPgcAAT4DAAEoAwABQAMAARADAAEB ARwB9AQAARwB9AQABHUBHAV1ARwFdTAAEHUwABB1IAABQgFNAT4HAAE+AwABKAMAAUADAAEQAwABAQEA
AQABAQUAAYAXAAP/AQAC/wYAAv8GAAL/BgAB8wHPBgAB8QHHBgAB8AHDBwABAR8AAQEGAAHwAcMGAAHx AQEFAAGAFwAD/wEAAv8GAAL/BgAC/wYAAfMBzwYAAfEBxwYAAfABwwcAAQEfAAEBBgAB8AHDBgAB8QHH
AccGAAHzAc8GAAL/BgAC/wYACw== BgAB8wHPBgAC/wYAAv8GAAs=
</value> </value>
</data> </data>
<metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">

View File

@ -213,6 +213,7 @@ namespace Nikse.SubtitleEdit.Logic
public bool ShowWaveForm { get; set; } public bool ShowWaveForm { get; set; }
public bool ShowFrameRate { get; set; } public bool ShowFrameRate { get; set; }
public double DefaultFrameRate { get; set; } public double DefaultFrameRate { get; set; }
public double CurrentFrameRate { get; set; }
public string DefaultEncoding { get; set; } public string DefaultEncoding { get; set; }
public bool AutoGuessAnsiEncoding { get; set; } public bool AutoGuessAnsiEncoding { get; set; }
public string SubtitleFontName { get; set; } public string SubtitleFontName { get; set; }
@ -271,6 +272,7 @@ namespace Nikse.SubtitleEdit.Logic
ShowWaveForm = false; ShowWaveForm = false;
ShowFrameRate = false; ShowFrameRate = false;
DefaultFrameRate = 23.976; DefaultFrameRate = 23.976;
CurrentFrameRate = DefaultFrameRate;
SubtitleFontName = "Tahoma"; SubtitleFontName = "Tahoma";
if (Environment.OSVersion.Version.Major < 6) // 6 == Vista/Win2008Server/Win7 if (Environment.OSVersion.Version.Major < 6) // 6 == Vista/Win2008Server/Win7
SubtitleFontName = Utilities.WinXp2kUnicodeFontName; SubtitleFontName = Utilities.WinXp2kUnicodeFontName;
@ -611,7 +613,10 @@ namespace Nikse.SubtitleEdit.Logic
settings.General.ShowWaveForm = Convert.ToBoolean(subNode.InnerText); settings.General.ShowWaveForm = Convert.ToBoolean(subNode.InnerText);
subNode = node.SelectSingleNode("DefaultFrameRate"); subNode = node.SelectSingleNode("DefaultFrameRate");
if (subNode != null) if (subNode != null)
{
settings.General.DefaultFrameRate = Convert.ToDouble(subNode.InnerText); settings.General.DefaultFrameRate = Convert.ToDouble(subNode.InnerText);
settings.General.CurrentFrameRate = Convert.ToDouble(subNode.InnerText);
}
subNode = node.SelectSingleNode("DefaultEncoding"); subNode = node.SelectSingleNode("DefaultEncoding");
if (subNode != null) if (subNode != null)
settings.General.DefaultEncoding = subNode.InnerText; settings.General.DefaultEncoding = subNode.InnerText;

View File

@ -0,0 +1,174 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Xml;
namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
{
class Captionate : SubtitleFormat
{
public override string Extension
{
get { return ".xml"; }
}
public override string Name
{
get { return "Xml"; }
}
public override bool HasLineNumber
{
get { return false; }
}
public override bool IsTimeBased
{
get { return true; }
}
public override bool IsMine(List<string> lines, string fileName)
{
Subtitle subtitle = new Subtitle();
this.LoadSubtitle(subtitle, lines, fileName);
return subtitle.Paragraphs.Count > 0;
}
public override string ToText(Subtitle subtitle, string title)
{
string xmlStructure = @"<captionate>
<timeformat>hh:mm:ss:ff/30</timeformat>
<namesareprefixed>namesareprefixed</namesareprefixed>
<captioninfo>
<trackinfo>
<track>
<displayname>Default</displayname>
<type/>
<languagecode/>
<targetwpm>140</targetwpm>
<stringdata/>
</track>
</trackinfo>
<speakerinfo>
</speakerinfo>
</captioninfo>
<captions></captions></captionate>";
XmlDocument xml = new XmlDocument();
xml.LoadXml(xmlStructure);
Paragraph last = null;
foreach (Paragraph p in subtitle.Paragraphs)
{
if (last != null)
{
if (last.EndTime.TotalMilliseconds + 500 < p.StartTime.TotalMilliseconds)
{
Paragraph blank = new Paragraph();
blank.StartTime.TotalMilliseconds = last.EndTime.TotalMilliseconds;
AddParagraph(xml, blank);
}
}
AddParagraph(xml, p);
last = p;
}
MemoryStream ms = new MemoryStream();
XmlTextWriter writer = new XmlTextWriter(ms, Encoding.UTF8);
writer.Formatting = Formatting.Indented;
xml.Save(writer);
return Encoding.UTF8.GetString(ms.ToArray()).Trim();
}
private void AddParagraph(XmlDocument xml, Paragraph p)
{
XmlNode paragraph = xml.CreateElement("caption");
XmlAttribute start = xml.CreateAttribute("time");
start.InnerText = EncodeTime(p.StartTime);
paragraph.Attributes.Append(start);
if (p.Text.Trim().Length > 0)
{
XmlNode tracks = xml.CreateElement("tracks");
paragraph.AppendChild(tracks);
XmlNode track0 = xml.CreateElement("track0");
track0.InnerText = Utilities.RemoveHtmlTags(p.Text);
track0.InnerXml = track0.InnerText.Replace(Environment.NewLine, "<br />");
tracks.AppendChild(track0);
}
xml.DocumentElement.SelectSingleNode("captions").AppendChild(paragraph);
}
public override void LoadSubtitle(Subtitle subtitle, List<string> lines, string fileName)
{
_errorCount = 0;
StringBuilder sb = new StringBuilder();
lines.ForEach(line => sb.AppendLine(line));
string xmlString = sb.ToString();
if (!xmlString.Contains("<captionate>") || !xmlString.Contains("</caption>"))
return;
XmlDocument xml = new XmlDocument();
try
{
xml.LoadXml(xmlString);
}
catch
{
_errorCount = 1;
return;
}
Paragraph p = null;
foreach (XmlNode node in xml.DocumentElement.SelectNodes("captions/caption"))
{
try
{
if (node.Attributes["time"] != null)
{
string start = node.Attributes["time"].InnerText;
double startMilliseconds = DecodeTimeToMilliseconds(start);
if (p != null)
p.EndTime.TotalMilliseconds = startMilliseconds - 1;
if (node.SelectSingleNode("tracks/track0") != null)
{
string text = node.SelectSingleNode("tracks/track0").InnerText;
text = Utilities.RemoveHtmlTags(text);
text = text.Replace("<br>", Environment.NewLine).Replace("<br />", Environment.NewLine).Replace("<BR>", Environment.NewLine);
p = new Paragraph(text, startMilliseconds, startMilliseconds + 3000);
if (text.Trim().Length > 0)
subtitle.Paragraphs.Add(p);
}
}
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine(ex.Message);
_errorCount++;
}
}
subtitle.Renumber(1);
}
private double DecodeTimeToMilliseconds(string time)
{
string[] parts = time.Split(":".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
TimeSpan ts = new TimeSpan(0, int.Parse(parts[0]), int.Parse(parts[1]), int.Parse(parts[2]), (int)(int.Parse(parts[3]) * 10.0));
return ts.TotalMilliseconds;
}
private string EncodeTime(TimeCode time)
{
return string.Format("{0:00}:{1:00}:{2:00}:{3:00}", time.Hours, time.Minutes, time.Seconds, time.Milliseconds / 10.0);
}
}
}

View File

@ -182,7 +182,7 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
private void WriteTime(FileStream fs, TimeCode timeCode) private void WriteTime(FileStream fs, TimeCode timeCode)
{ {
double totalMilliseconds = timeCode.TotalMilliseconds + TimeSpan.FromHours(10).TotalMilliseconds; // +10 hours double totalMilliseconds = timeCode.TotalMilliseconds + TimeSpan.FromHours(10).TotalMilliseconds; // +10 hours
int frames = (int)Math.Round(totalMilliseconds / (1000.0 /Configuration.Settings.General.DefaultFrameRate)); int frames = (int)Math.Round(totalMilliseconds / (1000.0 /Configuration.Settings.General.CurrentFrameRate));
fs.WriteByte((byte)(frames / 256 / 256)); fs.WriteByte((byte)(frames / 256 / 256));
fs.WriteByte((byte)(frames / 256)); fs.WriteByte((byte)(frames / 256));
fs.WriteByte((byte)(frames % 256)); fs.WriteByte((byte)(frames % 256));
@ -250,8 +250,8 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
Paragraph p = new Paragraph(); Paragraph p = new Paragraph();
p.Text = (line1 + Environment.NewLine + line2).Trim(); p.Text = (line1 + Environment.NewLine + line2).Trim();
p.StartTime.TotalMilliseconds = (double)((1000.0 / Configuration.Settings.General.DefaultFrameRate) * startFrame); p.StartTime.TotalMilliseconds = (double)((1000.0 / Configuration.Settings.General.CurrentFrameRate) * startFrame);
p.EndTime.TotalMilliseconds = (double)((1000.0 / Configuration.Settings.General.DefaultFrameRate) * endFrame); p.EndTime.TotalMilliseconds = (double)((1000.0 / Configuration.Settings.General.CurrentFrameRate) * endFrame);
subtitle.Paragraphs.Add(p); subtitle.Paragraphs.Add(p);
i += TextLength * 2; i += TextLength * 2;

View File

@ -46,7 +46,7 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
public override string ToText(Subtitle subtitle, string title) public override string ToText(Subtitle subtitle, string title)
{ {
if (Configuration.Settings.General.DefaultFrameRate > 26) if (Configuration.Settings.General.CurrentFrameRate > 26)
FrameRate = 30; FrameRate = 30;
else else
FrameRate = 25; FrameRate = 25;
@ -469,7 +469,7 @@ string xmlTrackStructure3b =
else else
track.InnerXml = xmlTrackStructure3b; track.InnerXml = xmlTrackStructure3b;
double frameRate = Configuration.Settings.General.DefaultFrameRate; double frameRate = Configuration.Settings.General.CurrentFrameRate;
XmlNode start = track.SelectSingleNode("generatoritem/start"); XmlNode start = track.SelectSingleNode("generatoritem/start");
start.InnerText = ((int)Math.Round(p.StartTime.TotalSeconds*frameRate)).ToString(); start.InnerText = ((int)Math.Round(p.StartTime.TotalSeconds*frameRate)).ToString();
@ -499,7 +499,7 @@ string xmlTrackStructure3b =
public override void LoadSubtitle(Subtitle subtitle, List<string> lines, string fileName) public override void LoadSubtitle(Subtitle subtitle, List<string> lines, string fileName)
{ {
_errorCount = 0; _errorCount = 0;
FrameRate = Configuration.Settings.General.DefaultFrameRate; FrameRate = Configuration.Settings.General.CurrentFrameRate;
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
lines.ForEach(line => sb.AppendLine(line)); lines.ForEach(line => sb.AppendLine(line));
@ -516,7 +516,7 @@ string xmlTrackStructure3b =
} }
catch catch
{ {
FrameRate = Configuration.Settings.General.DefaultFrameRate; FrameRate = Configuration.Settings.General.CurrentFrameRate;
} }
} }

View File

@ -46,7 +46,7 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
public override string ToText(Subtitle subtitle, string title) public override string ToText(Subtitle subtitle, string title)
{ {
if (Configuration.Settings.General.DefaultFrameRate > 26) if (Configuration.Settings.General.CurrentFrameRate > 26)
FrameRate = 30; FrameRate = 30;
else else
FrameRate = 25; FrameRate = 25;
@ -466,7 +466,7 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
XmlNode track = xml.CreateElement("track"); XmlNode track = xml.CreateElement("track");
track.InnerXml = xmlTrackStructure2; track.InnerXml = xmlTrackStructure2;
double frameRate = Configuration.Settings.General.DefaultFrameRate; double frameRate = Configuration.Settings.General.CurrentFrameRate;
XmlNode start = track.SelectSingleNode("generatoritem/start"); XmlNode start = track.SelectSingleNode("generatoritem/start");
start.InnerText = ((int)Math.Round(p.StartTime.TotalSeconds*frameRate)).ToString(); start.InnerText = ((int)Math.Round(p.StartTime.TotalSeconds*frameRate)).ToString();
@ -496,7 +496,7 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
public override void LoadSubtitle(Subtitle subtitle, List<string> lines, string fileName) public override void LoadSubtitle(Subtitle subtitle, List<string> lines, string fileName)
{ {
_errorCount = 0; _errorCount = 0;
FrameRate = Configuration.Settings.General.DefaultFrameRate; FrameRate = Configuration.Settings.General.CurrentFrameRate;
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
lines.ForEach(line => sb.AppendLine(line)); lines.ForEach(line => sb.AppendLine(line));
@ -513,7 +513,7 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
} }
catch catch
{ {
FrameRate = Configuration.Settings.General.DefaultFrameRate; FrameRate = Configuration.Settings.General.CurrentFrameRate;
} }
} }

View File

@ -55,7 +55,7 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
private string EncodeTimeCode(TimeCode time) private string EncodeTimeCode(TimeCode time)
{ {
//00:03:15:22 (last is frame) //00:03:15:22 (last is frame)
int frames = time.Milliseconds / (1000 / 30); int frames = (int) (time.Milliseconds / (1000.0 / Configuration.Settings.General.CurrentFrameRate));
return string.Format("{0:00}:{1:00}:{2:00}:{3:00}", time.Hours, time.Minutes, time.Seconds, frames); return string.Format("{0:00}:{1:00}:{2:00}:{3:00}", time.Hours, time.Minutes, time.Seconds, frames);
} }
@ -105,7 +105,7 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
string seconds = parts[2]; string seconds = parts[2];
string frames = parts[3]; string frames = parts[3];
int milliseconds = (int)((1000 / 30.0) * int.Parse(frames)); int milliseconds = (int)((1000.0 / Configuration.Settings.General.CurrentFrameRate) * int.Parse(frames));
if (milliseconds > 999) if (milliseconds > 999)
milliseconds = 999; milliseconds = 999;

View File

@ -18,6 +18,7 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
new AdobeEncore(), new AdobeEncore(),
new AdobeEncoreTab(), new AdobeEncoreTab(),
new AdobeEncoreWithLineNumbers(), new AdobeEncoreWithLineNumbers(),
new Captionate(),
new DCSubtitle(), new DCSubtitle(),
new DvdStudioPro(), new DvdStudioPro(),
new DvdSubtitle(), new DvdSubtitle(),

View File

@ -433,6 +433,7 @@ namespace Nikse.SubtitleEdit.Logic
s = s.Replace("</B>", string.Empty); s = s.Replace("</B>", string.Empty);
s = s.Replace("<U>", string.Empty); s = s.Replace("<U>", string.Empty);
s = s.Replace("</U>", string.Empty); s = s.Replace("</U>", string.Empty);
s = RemoveParagraphTag(s);
return RemoveHtmlFontTag(s); return RemoveHtmlFontTag(s);
} }
@ -453,6 +454,21 @@ namespace Nikse.SubtitleEdit.Logic
return s; return s;
} }
internal static string RemoveParagraphTag(string s)
{
s = s.Replace("</p>", string.Empty);
s = s.Replace("</P>", string.Empty);
s = s.Replace("<P>", string.Empty);
s = s.Replace("<P>", string.Empty);
while (s.ToLower().Contains("<p "))
{
int startIndex = s.ToLower().IndexOf("<p ");
int endIndex = Math.Max(s.IndexOf(">"), startIndex + 4);
s = s.Remove(startIndex, (endIndex - startIndex) + 1);
}
return s;
}
public static Encoding GetEncodingFromFile(string fileName) public static Encoding GetEncodingFromFile(string fileName)
{ {
Encoding encoding = Encoding.Default; Encoding encoding = Encoding.Default;

1195
src/Resources/eu-ES.xml Normal file

File diff suppressed because it is too large Load Diff

BIN
src/Resources/eu-ES.xml.zip Normal file

Binary file not shown.

View File

@ -535,6 +535,7 @@
<Compile Include="Logic\SubtitleFormats\AdobeEncoreTabs.cs" /> <Compile Include="Logic\SubtitleFormats\AdobeEncoreTabs.cs" />
<Compile Include="Logic\SubtitleFormats\AdobeEncoreWithLineNumbers.cs" /> <Compile Include="Logic\SubtitleFormats\AdobeEncoreWithLineNumbers.cs" />
<Compile Include="Logic\SubtitleFormats\BdnXml.cs" /> <Compile Include="Logic\SubtitleFormats\BdnXml.cs" />
<Compile Include="Logic\SubtitleFormats\Captionate.cs" />
<Compile Include="Logic\SubtitleFormats\Cavena890.cs" /> <Compile Include="Logic\SubtitleFormats\Cavena890.cs" />
<Compile Include="Logic\SubtitleFormats\DCSubtitle.cs" /> <Compile Include="Logic\SubtitleFormats\DCSubtitle.cs" />
<Compile Include="Logic\SubtitleFormats\FinalCutProTextXml.cs" /> <Compile Include="Logic\SubtitleFormats\FinalCutProTextXml.cs" />
@ -846,6 +847,7 @@
<EmbeddedResource Include="Resources\it-IT.xml.zip" /> <EmbeddedResource Include="Resources\it-IT.xml.zip" />
<EmbeddedResource Include="Resources\hu-HU.xml.zip" /> <EmbeddedResource Include="Resources\hu-HU.xml.zip" />
<EmbeddedResource Include="Resources\ja-JP.xml.zip" /> <EmbeddedResource Include="Resources\ja-JP.xml.zip" />
<EmbeddedResource Include="Resources\eu-ES.xml.zip" />
<None Include="Resources\pl-PL.xml"> <None Include="Resources\pl-PL.xml">
<SubType>Designer</SubType> <SubType>Designer</SubType>
</None> </None>
@ -898,6 +900,7 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Content Include="Resources\bg-BG.xml" /> <Content Include="Resources\bg-BG.xml" />
<Content Include="Resources\eu-ES.xml" />
<Content Include="Resources\fa-IR.xml"> <Content Include="Resources\fa-IR.xml">
<SubType>Designer</SubType> <SubType>Designer</SubType>
</Content> </Content>