@diplodoc/cli-tests 5.22.5 → 5.23.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -739,14 +739,44 @@ exports[`Translate command > do not resolve liquid conditions if vars not specif
739
739
  `;
740
740
 
741
741
  exports[`Translate command > do not resolve liquid conditions if vars not specified and send content as is for extract 1`] = `
742
- "#|
743
- ||
744
- %%%0%%%
745
- ||
746
- ||
747
- %%%1%%%{% endif %}
748
- ||
749
- |#"
742
+ "%%%0%%%
743
+ <!-- [missed file](./missed.md) -->
744
+ {% if prod == true %}%%%1%%%{% endif %}
745
+
746
+ {% if inner == true %}%%%2%%%{% endif %}
747
+
748
+ {% if prod == true %}%%%3%%%{% endif %}{% endif %}
749
+
750
+ {% if prod == true %}
751
+
752
+ {% if list contains "item" %}
753
+
754
+ %%%4%%%
755
+
756
+ {% if item == true %}%%%5%%% %%%6%%% {% endif %}
757
+
758
+ %%%7%%%
759
+
760
+ {% endif %}
761
+
762
+ {% endif %}
763
+
764
+ #### %%%8%%%
765
+
766
+ {% if list contains "item" %}
767
+
768
+ %%%9%%%
769
+
770
+ {% endif %}
771
+
772
+ #### %%%10%%%
773
+
774
+ {% if prod == true %}
775
+
776
+ %%%11%%% {% endif %}
777
+
778
+ {% endif %}
779
+ "
750
780
  `;
751
781
 
752
782
  exports[`Translate command > do not resolve liquid conditions if vars not specified and send content as is for extract 2`] = `
@@ -760,10 +790,40 @@ exports[`Translate command > do not resolve liquid conditions if vars not specif
760
790
  </header>
761
791
  <body>
762
792
  <trans-unit id="0">
763
- <source xml:space="preserve"><g ctype="bold" equiv-text="**{{text}}**" id="g-1" x-begin="**" x-end="**">Заголовок</g></source>
793
+ <source xml:space="preserve"><g ctype="link" equiv-text="[{{text}}](./exists.md)" id="g-1" x-begin="[" x-end="](./exists.md)">existing file</g></source>
764
794
  </trans-unit>
765
795
  <trans-unit id="1">
766
- <source xml:space="preserve">Доступны в любом отчете в виде <g ctype="link" equiv-text="[{{text}}](../general/goals.md)" id="g-2" x-begin="[" x-end="](../general/goals.md)">целей</g>, а также в отчетах:<x ctype="lb" equiv-text="&amp;#10;" id="x-1"/><x ctype="liquid_Literal" equiv-text="{% if tld == &quot;ru&quot; or tld == &quot;es&quot; or tld == &quot;pt&quot; or tld == &quot;com&quot; or tld == &quot;tr&quot; %}" id="x-2"/>- <g ctype="link" equiv-text="[{{text}}](../reports/ecommerce.md)" id="g-3" x-begin="[" x-end="](../reports/ecommerce.md)">электронной коммерции</g><x ctype="liquid_Literal" equiv-text="{% endif %}" id="x-3"/><x ctype="liquid_Literal" equiv-text="{% if tld == &quot;zh&quot; %}" id="x-4"/>- электронной коммерции<x ctype="liquid_Literal" equiv-text="{% endif %}" id="x-5"/>;<x ctype="lb" equiv-text="&amp;#10;" id="x-6"/><x ctype="liquid_Literal" equiv-text="{% if tld == &quot;ru&quot;%}" id="x-7"/>- <g ctype="link" equiv-text="[{{text}}](../data/user-params-data.md)" id="g-4" x-begin="[" x-end="](../data/user-params-data.md)">по параметрам посетителей</g><x ctype="liquid_Literal" equiv-text="{% endif %}" id="x-8"/><x ctype="liquid_Literal" equiv-text="{% if tld == &quot;es&quot; or tld == &quot;pt&quot; or tld == &quot;com&quot; or tld == &quot;zh&quot; or tld == &quot;tr&quot; %}" id="x-9"/>- по параметрам посетителей<x ctype="liquid_Literal" equiv-text="{% endif %}" id="x-10"/>;<x ctype="lb" equiv-text="&amp;#10;" id="x-11"/><x ctype="liquid_Literal" equiv-text="{% if tld == &quot;ru&quot; or tld == &quot;es&quot; or tld == &quot;pt&quot; or tld == &quot;com&quot; or tld == &quot;tr&quot; %}" id="x-12"/>- <g ctype="link" equiv-text="[{{text}}](../data/visit-params-data.md)" id="g-5" x-begin="[" x-end="](../data/visit-params-data.md)">по параметрам визитов</g><x ctype="liquid_Literal" equiv-text="{% endif %}" id="x-13"/><x ctype="liquid_Literal" equiv-text="{% if tld == &quot;zh&quot; %}" id="x-14"/>- по параметрам визитов</source>
796
+ <source xml:space="preserve">Test text</source>
797
+ </trans-unit>
798
+ <trans-unit id="2">
799
+ <source xml:space="preserve">inner test text</source>
800
+ </trans-unit>
801
+ <trans-unit id="3">
802
+ <source xml:space="preserve">Test text<x ctype="liquid_Literal" equiv-text="{% if inner == true %}" id="x-1"/>inner test text</source>
803
+ </trans-unit>
804
+ <trans-unit id="4">
805
+ <source xml:space="preserve">#### List</source>
806
+ </trans-unit>
807
+ <trans-unit id="5">
808
+ <source xml:space="preserve">1.</source>
809
+ </trans-unit>
810
+ <trans-unit id="6">
811
+ <source xml:space="preserve">Item</source>
812
+ </trans-unit>
813
+ <trans-unit id="7">
814
+ <source xml:space="preserve">Some text</source>
815
+ </trans-unit>
816
+ <trans-unit id="8">
817
+ <source xml:space="preserve">Standalone contains condition</source>
818
+ </trans-unit>
819
+ <trans-unit id="9">
820
+ <source xml:space="preserve">#### List</source>
821
+ </trans-unit>
822
+ <trans-unit id="10">
823
+ <source xml:space="preserve">Inline contains condition</source>
824
+ </trans-unit>
825
+ <trans-unit id="11">
826
+ <source xml:space="preserve">#### List <x ctype="liquid_Literal" equiv-text="{% if list contains &quot;item&quot; %}" id="x-2"/> sub text</source>
767
827
  </trans-unit>
768
828
  </body>
769
829
  </file>
@@ -1695,6 +1755,92 @@ exports[`Translate command > filter files on extract with extra vars option > fi
1695
1755
  ]"
1696
1756
  `;
1697
1757
 
1758
+ exports[`Translate command > remove falsy liquid conditions structures > filelist 1`] = `
1759
+ "[
1760
+ "index.md.skl",
1761
+ "index.md.xliff",
1762
+ "toc.yaml.skl",
1763
+ "toc.yaml.xliff"
1764
+ ]"
1765
+ `;
1766
+
1767
+ exports[`Translate command > remove falsy liquid conditions structures 1`] = `
1768
+ "%%%0%%%
1769
+ <!-- [missed file](./missed.md) -->
1770
+
1771
+
1772
+
1773
+
1774
+ #### %%%1%%%
1775
+
1776
+ {% if list contains "item" %}
1777
+
1778
+ %%%2%%%
1779
+
1780
+ {% endif %}
1781
+
1782
+ #### %%%3%%%
1783
+
1784
+ "
1785
+ `;
1786
+
1787
+ exports[`Translate command > remove falsy liquid conditions structures 2`] = `
1788
+ "<?xml version="1.0" encoding="UTF-8"?>
1789
+ <xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" version="1.2">
1790
+ <file original="file.ext" source-language="ru-RU" target-language="es-ES" datatype="markdown">
1791
+ <header>
1792
+ <skeleton>
1793
+ <external-file href="file.skl"></external-file>
1794
+ </skeleton>
1795
+ </header>
1796
+ <body>
1797
+ <trans-unit id="0">
1798
+ <source xml:space="preserve"><g ctype="link" equiv-text="[{{text}}](./exists.md)" id="g-1" x-begin="[" x-end="](./exists.md)">existing file</g></source>
1799
+ </trans-unit>
1800
+ <trans-unit id="1">
1801
+ <source xml:space="preserve">Standalone contains condition</source>
1802
+ </trans-unit>
1803
+ <trans-unit id="2">
1804
+ <source xml:space="preserve">#### List</source>
1805
+ </trans-unit>
1806
+ <trans-unit id="3">
1807
+ <source xml:space="preserve">Inline contains condition</source>
1808
+ </trans-unit>
1809
+ </body>
1810
+ </file>
1811
+ </xliff>"
1812
+ `;
1813
+
1814
+ exports[`Translate command > remove falsy liquid conditions structures 3`] = `
1815
+ "title: '%%%0%%%'
1816
+ href: index.md
1817
+ items:
1818
+ - name: '%%%1%%%'
1819
+ href: index.md
1820
+ "
1821
+ `;
1822
+
1823
+ exports[`Translate command > remove falsy liquid conditions structures 4`] = `
1824
+ "<?xml version="1.0" encoding="UTF-8"?>
1825
+ <xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" version="1.2">
1826
+ <file original="file.ext" source-language="ru-RU" target-language="es-ES" datatype="markdown">
1827
+ <header>
1828
+ <skeleton>
1829
+ <external-file href="file.skl"></external-file>
1830
+ </skeleton>
1831
+ </header>
1832
+ <body>
1833
+ <trans-unit id="0">
1834
+ <source xml:space="preserve">Conditions</source>
1835
+ </trans-unit>
1836
+ <trans-unit id="1">
1837
+ <source xml:space="preserve">Example</source>
1838
+ </trans-unit>
1839
+ </body>
1840
+ </file>
1841
+ </xliff>"
1842
+ `;
1843
+
1698
1844
  exports[`Translate command > resolve liquid conditions if vars specified, liquid syntax will be deleted > filelist 1`] = `
1699
1845
  "[
1700
1846
  "index.md.skl",
@@ -1705,17 +1851,44 @@ exports[`Translate command > resolve liquid conditions if vars specified, liquid
1705
1851
  `;
1706
1852
 
1707
1853
  exports[`Translate command > resolve liquid conditions if vars specified, liquid syntax will be deleted 1`] = `
1708
- "#|
1709
- ||
1710
- %%%0%%%
1711
- ||
1712
- ||
1713
- %%%1%%%
1714
- - %%%2%%%
1715
- - %%%3%%%
1716
- - %%%4%%%
1717
- ||
1718
- |#"
1854
+ "%%%0%%%
1855
+ <!-- [missed file](./missed.md) -->
1856
+ {% if prod == true %}%%%1%%%{% endif %}
1857
+
1858
+ {% if inner == true %}%%%2%%%{% endif %}
1859
+
1860
+ {% if prod == true %}%%%3%%%{% endif %}{% endif %}
1861
+
1862
+ {% if prod == true %}
1863
+
1864
+ {% if list contains "item" %}
1865
+
1866
+ %%%4%%%
1867
+
1868
+ {% if item == true %}%%%5%%% %%%6%%% {% endif %}
1869
+
1870
+ %%%7%%%
1871
+
1872
+ {% endif %}
1873
+
1874
+ {% endif %}
1875
+
1876
+ #### %%%8%%%
1877
+
1878
+ {% if list contains "item" %}
1879
+
1880
+ %%%9%%%
1881
+
1882
+ {% endif %}
1883
+
1884
+ #### %%%10%%%
1885
+
1886
+ {% if prod == true %}
1887
+
1888
+ %%%11%%% {% endif %}
1889
+
1890
+ {% endif %}
1891
+ "
1719
1892
  `;
1720
1893
 
1721
1894
  exports[`Translate command > resolve liquid conditions if vars specified, liquid syntax will be deleted 2`] = `
@@ -1729,19 +1902,40 @@ exports[`Translate command > resolve liquid conditions if vars specified, liquid
1729
1902
  </header>
1730
1903
  <body>
1731
1904
  <trans-unit id="0">
1732
- <source xml:space="preserve"><g ctype="bold" equiv-text="**{{text}}**" id="g-1" x-begin="**" x-end="**">Заголовок</g></source>
1905
+ <source xml:space="preserve"><g ctype="link" equiv-text="[{{text}}](./exists.md)" id="g-1" x-begin="[" x-end="](./exists.md)">existing file</g></source>
1733
1906
  </trans-unit>
1734
1907
  <trans-unit id="1">
1735
- <source xml:space="preserve">Доступны в любом отчете в виде <g ctype="link" equiv-text="[{{text}}](../general/goals.md)" id="g-2" x-begin="[" x-end="](../general/goals.md)">целей</g>, а также в отчетах:</source>
1908
+ <source xml:space="preserve">Test text</source>
1736
1909
  </trans-unit>
1737
1910
  <trans-unit id="2">
1738
- <source xml:space="preserve"><g ctype="link" equiv-text="[{{text}}](../reports/ecommerce.md)" id="g-3" x-begin="[" x-end="](../reports/ecommerce.md)">электронной коммерции</g>;</source>
1911
+ <source xml:space="preserve">inner test text</source>
1739
1912
  </trans-unit>
1740
1913
  <trans-unit id="3">
1741
- <source xml:space="preserve"><g ctype="link" equiv-text="[{{text}}](../data/user-params-data.md)" id="g-4" x-begin="[" x-end="](../data/user-params-data.md)">по параметрам посетителей</g>;</source>
1914
+ <source xml:space="preserve">Test text<x ctype="liquid_Literal" equiv-text="{% if inner == true %}" id="x-1"/>inner test text</source>
1742
1915
  </trans-unit>
1743
1916
  <trans-unit id="4">
1744
- <source xml:space="preserve"><g ctype="link" equiv-text="[{{text}}](../data/visit-params-data.md)" id="g-5" x-begin="[" x-end="](../data/visit-params-data.md)">по параметрам визитов</g></source>
1917
+ <source xml:space="preserve">#### List</source>
1918
+ </trans-unit>
1919
+ <trans-unit id="5">
1920
+ <source xml:space="preserve">1.</source>
1921
+ </trans-unit>
1922
+ <trans-unit id="6">
1923
+ <source xml:space="preserve">Item</source>
1924
+ </trans-unit>
1925
+ <trans-unit id="7">
1926
+ <source xml:space="preserve">Some text</source>
1927
+ </trans-unit>
1928
+ <trans-unit id="8">
1929
+ <source xml:space="preserve">Standalone contains condition</source>
1930
+ </trans-unit>
1931
+ <trans-unit id="9">
1932
+ <source xml:space="preserve">#### List</source>
1933
+ </trans-unit>
1934
+ <trans-unit id="10">
1935
+ <source xml:space="preserve">Inline contains condition</source>
1936
+ </trans-unit>
1937
+ <trans-unit id="11">
1938
+ <source xml:space="preserve">#### List <x ctype="liquid_Literal" equiv-text="{% if list contains &quot;item&quot; %}" id="x-2"/> sub text</source>
1745
1939
  </trans-unit>
1746
1940
  </body>
1747
1941
  </file>
@@ -1778,6 +1972,137 @@ exports[`Translate command > resolve liquid conditions if vars specified, liquid
1778
1972
  </xliff>"
1779
1973
  `;
1780
1974
 
1975
+ exports[`Translate command > save truthy liquid conditions structures > filelist 1`] = `
1976
+ "[
1977
+ "index.md.skl",
1978
+ "index.md.xliff",
1979
+ "toc.yaml.skl",
1980
+ "toc.yaml.xliff"
1981
+ ]"
1982
+ `;
1983
+
1984
+ exports[`Translate command > save truthy liquid conditions structures 1`] = `
1985
+ "%%%0%%%
1986
+ <!-- [missed file](./missed.md) -->
1987
+ {% if prod == true %}%%%1%%%{% endif %}
1988
+
1989
+ {% if inner == true %}%%%2%%%{% endif %}
1990
+
1991
+ {% if prod == true %}%%%3%%%{% endif %}{% endif %}
1992
+
1993
+ {% if prod == true %}
1994
+
1995
+ {% if list contains "item" %}
1996
+
1997
+ %%%4%%%
1998
+
1999
+ {% if item == true %}%%%5%%% %%%6%%% {% endif %}
2000
+
2001
+ %%%7%%%
2002
+
2003
+ {% endif %}
2004
+
2005
+ {% endif %}
2006
+
2007
+ #### %%%8%%%
2008
+
2009
+ {% if list contains "item" %}
2010
+
2011
+ %%%9%%%
2012
+
2013
+ {% endif %}
2014
+
2015
+ #### %%%10%%%
2016
+
2017
+ {% if prod == true %}
2018
+
2019
+ %%%11%%% {% endif %}
2020
+
2021
+ {% endif %}
2022
+ "
2023
+ `;
2024
+
2025
+ exports[`Translate command > save truthy liquid conditions structures 2`] = `
2026
+ "<?xml version="1.0" encoding="UTF-8"?>
2027
+ <xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" version="1.2">
2028
+ <file original="file.ext" source-language="ru-RU" target-language="es-ES" datatype="markdown">
2029
+ <header>
2030
+ <skeleton>
2031
+ <external-file href="file.skl"></external-file>
2032
+ </skeleton>
2033
+ </header>
2034
+ <body>
2035
+ <trans-unit id="0">
2036
+ <source xml:space="preserve"><g ctype="link" equiv-text="[{{text}}](./exists.md)" id="g-1" x-begin="[" x-end="](./exists.md)">existing file</g></source>
2037
+ </trans-unit>
2038
+ <trans-unit id="1">
2039
+ <source xml:space="preserve">Test text</source>
2040
+ </trans-unit>
2041
+ <trans-unit id="2">
2042
+ <source xml:space="preserve">inner test text</source>
2043
+ </trans-unit>
2044
+ <trans-unit id="3">
2045
+ <source xml:space="preserve">Test text<x ctype="liquid_Literal" equiv-text="{% if inner == true %}" id="x-1"/>inner test text</source>
2046
+ </trans-unit>
2047
+ <trans-unit id="4">
2048
+ <source xml:space="preserve">#### List</source>
2049
+ </trans-unit>
2050
+ <trans-unit id="5">
2051
+ <source xml:space="preserve">1.</source>
2052
+ </trans-unit>
2053
+ <trans-unit id="6">
2054
+ <source xml:space="preserve">Item</source>
2055
+ </trans-unit>
2056
+ <trans-unit id="7">
2057
+ <source xml:space="preserve">Some text</source>
2058
+ </trans-unit>
2059
+ <trans-unit id="8">
2060
+ <source xml:space="preserve">Standalone contains condition</source>
2061
+ </trans-unit>
2062
+ <trans-unit id="9">
2063
+ <source xml:space="preserve">#### List</source>
2064
+ </trans-unit>
2065
+ <trans-unit id="10">
2066
+ <source xml:space="preserve">Inline contains condition</source>
2067
+ </trans-unit>
2068
+ <trans-unit id="11">
2069
+ <source xml:space="preserve">#### List <x ctype="liquid_Literal" equiv-text="{% if list contains &quot;item&quot; %}" id="x-2"/> sub text</source>
2070
+ </trans-unit>
2071
+ </body>
2072
+ </file>
2073
+ </xliff>"
2074
+ `;
2075
+
2076
+ exports[`Translate command > save truthy liquid conditions structures 3`] = `
2077
+ "title: '%%%0%%%'
2078
+ href: index.md
2079
+ items:
2080
+ - name: '%%%1%%%'
2081
+ href: index.md
2082
+ "
2083
+ `;
2084
+
2085
+ exports[`Translate command > save truthy liquid conditions structures 4`] = `
2086
+ "<?xml version="1.0" encoding="UTF-8"?>
2087
+ <xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" version="1.2">
2088
+ <file original="file.ext" source-language="ru-RU" target-language="es-ES" datatype="markdown">
2089
+ <header>
2090
+ <skeleton>
2091
+ <external-file href="file.skl"></external-file>
2092
+ </skeleton>
2093
+ </header>
2094
+ <body>
2095
+ <trans-unit id="0">
2096
+ <source xml:space="preserve">Conditions</source>
2097
+ </trans-unit>
2098
+ <trans-unit id="1">
2099
+ <source xml:space="preserve">Example</source>
2100
+ </trans-unit>
2101
+ </body>
2102
+ </file>
2103
+ </xliff>"
2104
+ `;
2105
+
1781
2106
  exports[`Translate command > test no-translate directive > filelist 1`] = `
1782
2107
  "[
1783
2108
  "index.md.skl",
@@ -186,4 +186,30 @@ describe('Translate command', () => {
186
186
  source: 'ru-RU',
187
187
  target: 'en-US',
188
188
  });
189
+
190
+ let conditionVars = {prod: true, inner: true, list: ['item']};
191
+ generateMapTestTemplate(
192
+ 'save truthy liquid conditions structures',
193
+ 'mocks/translation/conditions',
194
+ {
195
+ subcommand: 'extract',
196
+ source: 'ru-RU',
197
+ target: 'es-ES',
198
+ additionalArgs: `--vars ${JSON.stringify(conditionVars)}`,
199
+ },
200
+ false,
201
+ );
202
+
203
+ conditionVars = {prod: false, inner: false, list: ['item']};
204
+ generateMapTestTemplate(
205
+ 'remove falsy liquid conditions structures',
206
+ 'mocks/translation/conditions',
207
+ {
208
+ subcommand: 'extract',
209
+ source: 'ru-RU',
210
+ target: 'es-ES',
211
+ additionalArgs: `--vars ${JSON.stringify(conditionVars)}`,
212
+ },
213
+ false,
214
+ );
189
215
  });
@@ -4,4 +4,4 @@
4
4
 
5
5
  [second missed link](./filtered2.md)
6
6
  [second missed link](./filtered2.md)
7
- [second missed link](./filtered3.md)
7
+ [second missed link](./filtered3.md)
@@ -1,11 +1,37 @@
1
- #|
2
- ||
3
- **Заголовок**
4
- ||
5
- ||
6
- Доступны в любом отчете в виде [целей](../general/goals.md), а также в отчетах:
7
- {% if tld == "ru" or tld == "es" or tld == "pt" or tld == "com" or tld == "tr" %}- [электронной коммерции](../reports/ecommerce.md){% endif %}{% if tld == "zh" %}- электронной коммерции{% endif %};
8
- {% if tld == "ru"%}- [по параметрам посетителей](../data/user-params-data.md){% endif %}{% if tld == "es" or tld == "pt" or tld == "com" or tld == "zh" or tld == "tr" %}- по параметрам посетителей{% endif %};
9
- {% if tld == "ru" or tld == "es" or tld == "pt" or tld == "com" or tld == "tr" %}- [по параметрам визитов](../data/visit-params-data.md){% endif %}{% if tld == "zh" %}- по параметрам визитов{% endif %}
10
- ||
11
- |#
1
+ [existing file](./exists.md)
2
+ <!-- [missed file](./missed.md) -->
3
+ {% if prod == true %}Test text{% endif %}
4
+
5
+ {% if inner == true %}inner test text{% endif %}
6
+
7
+ {% if prod == true %}Test text{% if inner == true %}inner test text{% endif %}{% endif %}
8
+
9
+ {% if prod == true %}
10
+
11
+ {% if list contains "item" %}
12
+
13
+ #### List
14
+
15
+ {% if item == true %}1. Item {% endif %}
16
+
17
+ Some text
18
+
19
+ {% endif %}
20
+
21
+ {% endif %}
22
+
23
+ #### Standalone contains condition
24
+
25
+ {% if list contains "item" %}
26
+
27
+ #### List
28
+
29
+ {% endif %}
30
+
31
+ #### Inline contains condition
32
+
33
+ {% if prod == true %}
34
+
35
+ #### List {% if list contains "item" %} sub text {% endif %}
36
+
37
+ {% endif %}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@diplodoc/cli-tests",
3
- "version": "5.22.5",
3
+ "version": "5.23.0",
4
4
  "bin": {
5
5
  "diplodoc-cli-test": "bin.mjs"
6
6
  },