mirror of
https://github.com/KevinMidboe/linguist.git
synced 2025-10-29 17:50:22 +00:00
Merge pull request #886 from ruben2020/master
Fix for *.ts conflict between TypeScript and Qt Translation files
This commit is contained in:
@@ -19,6 +19,9 @@ module Linguist
|
|||||||
if languages.all? { |l| ["Perl", "Prolog"].include?(l) }
|
if languages.all? { |l| ["Perl", "Prolog"].include?(l) }
|
||||||
disambiguate_pl(data, languages)
|
disambiguate_pl(data, languages)
|
||||||
end
|
end
|
||||||
|
if languages.all? { |l| ["TypeScript", "XML"].include?(l) }
|
||||||
|
disambiguate_ts(data, languages)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -40,6 +43,16 @@ module Linguist
|
|||||||
matches
|
matches
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.disambiguate_ts(data, languages)
|
||||||
|
matches = []
|
||||||
|
if (data.include?("</translation>"))
|
||||||
|
matches << Language["XML"]
|
||||||
|
else
|
||||||
|
matches << Language["TypeScript"]
|
||||||
|
end
|
||||||
|
matches
|
||||||
|
end
|
||||||
|
|
||||||
def self.active?
|
def self.active?
|
||||||
!!ACTIVE
|
!!ACTIVE
|
||||||
end
|
end
|
||||||
|
|||||||
47
samples/XML/pt_BR.xml
Normal file
47
samples/XML/pt_BR.xml
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!DOCTYPE TS>
|
||||||
|
<TS version="2.0" language="pt_BR">
|
||||||
|
<context>
|
||||||
|
<name>MainWindow</name>
|
||||||
|
<message>
|
||||||
|
<location filename="../forms/mainwindow.ui" line="22"/>
|
||||||
|
<source>United Kingdom</source>
|
||||||
|
<translation>Reino Unido</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../forms/mainwindow.ui" line="38"/>
|
||||||
|
<source>God save the Queen</source>
|
||||||
|
<translation>Deus salve a Rainha</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../mainwindow.cpp" line="46"/>
|
||||||
|
<source>England</source>
|
||||||
|
<translation>Inglaterra</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../mainwindow.cpp" line="47"/>
|
||||||
|
<source>Wales</source>
|
||||||
|
<translation>Gales</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../mainwindow.cpp" line="48"/>
|
||||||
|
<source>Scotland</source>
|
||||||
|
<translation>Escócia</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../mainwindow.cpp" line="49"/>
|
||||||
|
<source>Northern Ireland</source>
|
||||||
|
<translation>Irlanda Norte</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../mainwindow.cpp" line="51"/>
|
||||||
|
<source>Portuguese</source>
|
||||||
|
<translation>Português</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../mainwindow.cpp" line="52"/>
|
||||||
|
<source>English</source>
|
||||||
|
<translation>Inglês</translation>
|
||||||
|
</message>
|
||||||
|
</context>
|
||||||
|
</TS>
|
||||||
@@ -50,4 +50,16 @@ class TestHeuristcs < Test::Unit::TestCase
|
|||||||
results = Heuristics.disambiguate_pl(fixture("Perl/perl-test.t"), languages)
|
results = Heuristics.disambiguate_pl(fixture("Perl/perl-test.t"), languages)
|
||||||
assert_equal Language["Perl"], results.first
|
assert_equal Language["Perl"], results.first
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_ts_typescript_by_heuristics
|
||||||
|
languages = ["TypeScript", "XML"]
|
||||||
|
results = Heuristics.disambiguate_ts(fixture("TypeScript/classes.ts"), languages)
|
||||||
|
assert_equal Language["TypeScript"], results.first
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_ts_xml_by_heuristics
|
||||||
|
languages = ["TypeScript", "XML"]
|
||||||
|
results = Heuristics.disambiguate_ts(fixture("XML/pt_BR.xml"), languages)
|
||||||
|
assert_equal Language["XML"], results.first
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user