forked from box/mojito
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for HTML files in the webapp
Basic support works but 1) the text unit name will change as soon as there is a change to the document which will prevent basic leveraging. It is just using an auto increment for new text unit. We need to look into some different logic for that, eg. md5 hashing of previous content + occurence count 2) if there are image, and maybe some other html element, they just get replaced by a placeholder in the localized file. Need to debug.
- Loading branch information
Showing
23 changed files
with
302 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
cli/src/main/java/com/box/l10n/mojito/cli/filefinder/file/HtmlFileType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package com.box.l10n.mojito.cli.filefinder.file; | ||
|
||
/** @author jaurambault */ | ||
public class HtmlFileType extends LocaleInNameFileType { | ||
|
||
public HtmlFileType() { | ||
this.sourceFileExtension = "html"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
cli/src/test/java/com/box/l10n/mojito/cli/filefinder/file/HtmlFileTypeTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package com.box.l10n.mojito.cli.filefinder.file; | ||
|
||
import static com.box.l10n.mojito.cli.filefinder.FilePattern.BASE_NAME; | ||
import static com.box.l10n.mojito.cli.filefinder.FilePattern.FILE_EXTENSION; | ||
import static com.box.l10n.mojito.cli.filefinder.FilePattern.LOCALE; | ||
import static com.box.l10n.mojito.cli.filefinder.FilePattern.PARENT_PATH; | ||
|
||
import com.box.l10n.mojito.cli.filefinder.FilePattern; | ||
import java.util.regex.Matcher; | ||
import org.junit.Assert; | ||
import org.junit.Test; | ||
|
||
/** @author jaurambault */ | ||
public class HtmlFileTypeTest { | ||
|
||
@Test | ||
public void testSourcePattern() { | ||
HtmlFileType htmlFileType = new HtmlFileType(); | ||
FilePattern sourceFilePattern = htmlFileType.getSourceFilePattern(); | ||
Matcher matcher = sourceFilePattern.getPattern().matcher("/source/filefinder.html"); | ||
Assert.assertTrue(matcher.matches()); | ||
Assert.assertEquals("/source/", matcher.group(PARENT_PATH)); | ||
Assert.assertEquals("filefinder", matcher.group(BASE_NAME)); | ||
Assert.assertEquals("html", matcher.group(FILE_EXTENSION)); | ||
} | ||
|
||
@Test | ||
public void testTargetPattern() { | ||
HtmlFileType htmlFileType = new HtmlFileType(); | ||
Matcher matcher = | ||
htmlFileType.getTargetFilePattern().getPattern().matcher("/source/filefinder_fr.html"); | ||
Assert.assertTrue(matcher.matches()); | ||
Assert.assertEquals("fr", matcher.group(LOCALE)); | ||
Assert.assertEquals("/source/", matcher.group(PARENT_PATH)); | ||
Assert.assertEquals("filefinder", matcher.group(BASE_NAME)); | ||
Assert.assertEquals("html", matcher.group(FILE_EXTENSION)); | ||
} | ||
|
||
@Test | ||
public void testTargetPatternBcp47() { | ||
HtmlFileType htmlFileType = new HtmlFileType(); | ||
Matcher matcher = | ||
htmlFileType.getTargetFilePattern().getPattern().matcher("/source/filefinder_fr-FR.html"); | ||
Assert.assertTrue(matcher.matches()); | ||
Assert.assertEquals("fr-FR", matcher.group(LOCALE)); | ||
Assert.assertEquals("/source/", matcher.group(PARENT_PATH)); | ||
Assert.assertEquals("filefinder", matcher.group(BASE_NAME)); | ||
Assert.assertEquals("html", matcher.group(FILE_EXTENSION)); | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
...m/box/l10n/mojito/cli/command/PullCommandTest_IO/pullHtml/expected/target/demo_fr-CA.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<html> | ||
<p>100 character description:</p> | ||
<ul> | ||
<li>15 min</li> | ||
<li>1 day</li> | ||
<li>1 hour</li> | ||
<li>1 month</li> | ||
</ul>[#$dp12]</html> |
8 changes: 8 additions & 0 deletions
8
.../com/box/l10n/mojito/cli/command/PullCommandTest_IO/pullHtml/expected/target/demo_fr.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<html> | ||
<p>100 character description:</p> | ||
<ul> | ||
<li>15 min</li> | ||
<li>1 day</li> | ||
<li>1 hour</li> | ||
<li>1 month</li> | ||
</ul>[#$dp12]</html> |
8 changes: 8 additions & 0 deletions
8
.../com/box/l10n/mojito/cli/command/PullCommandTest_IO/pullHtml/expected/target/demo_ja.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<html> | ||
<p>100 character description:</p> | ||
<ul> | ||
<li>15 min</li> | ||
<li>1 day</li> | ||
<li>1 hour</li> | ||
<li>1 month</li> | ||
</ul>[#$dp12]</html> |
10 changes: 10 additions & 0 deletions
10
...ources/com/box/l10n/mojito/cli/command/PullCommandTest_IO/pullHtml/input/source/demo.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<html> | ||
<p>100 character description:</p> | ||
<ul> | ||
<li>15 min</li> | ||
<li>1 day</li> | ||
<li>1 hour</li> | ||
<li>1 month</li> | ||
</ul> | ||
<img src="this-is-causing-issues.jpg"> | ||
</html> |
48 changes: 48 additions & 0 deletions
48
...ojito/cli/command/PullCommandTest_IO/pullHtml/input/translations/source-xliff_fr-FR.xliff
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:okp="okapi-framework:xliff-extensions" version="1.2"> | ||
<file original="" source-language="en" target-language="fr-FR" datatype="x-undefined"> | ||
<body> | ||
<!-- TODO update when it is decided how to process the text unit name and if we support comments --> | ||
<!-- <trans-unit id="" resname="100 character description:" datatype="php"> --> | ||
<!-- <source>100 character description:</source> --> | ||
<!-- <target>Description de 100 caractères :</target> --> | ||
<!-- </trans-unit> --> | ||
<!-- <trans-unit id="" resname="15 min" datatype="x-javascript+php"> --> | ||
<!-- <source>15 min</source> --> | ||
<!-- <target>15 min</target> --> | ||
<!-- </trans-unit> --> | ||
<!-- <trans-unit id="" resname="1 day" datatype="x-javascript+php"> --> | ||
<!-- <source>1 day</source> --> | ||
<!-- <target>1 jour</target> --> | ||
<!-- </trans-unit> --> | ||
<!-- <trans-unit id="" resname="1 hour" datatype="x-javascript+php"> --> | ||
<!-- <source>1 hour</source> --> | ||
<!-- <target>1 heure</target> --> | ||
<!-- </trans-unit> --> | ||
<!-- <trans-unit id="" resname="1 month" datatype="x-javascript+php"> --> | ||
<!-- <source>1 month</source> --> | ||
<!-- <target>1 mois</target> --> | ||
<!-- </trans-unit> --> | ||
<trans-unit id="" resname="tu1" datatype="php"> | ||
<source>100 character description:</source> | ||
<target>Description de 100 caractères :</target> | ||
</trans-unit> | ||
<trans-unit id="" resname="tu2" datatype="x-javascript+php"> | ||
<source>15 min</source> | ||
<target>15 min</target> | ||
</trans-unit> | ||
<trans-unit id="" resname="tu3" datatype="x-javascript+php"> | ||
<source>1 day</source> | ||
<target>1 jour</target> | ||
</trans-unit> | ||
<trans-unit id="" resname="tu4" datatype="x-javascript+php"> | ||
<source>1 hour</source> | ||
<target>1 heure</target> | ||
</trans-unit> | ||
<trans-unit id="" resname="tu5" datatype="x-javascript+php"> | ||
<source>1 month</source> | ||
<target>1 mois</target>¬ | ||
</trans-unit> | ||
</body> | ||
</file> | ||
</xliff> |
27 changes: 27 additions & 0 deletions
27
...ojito/cli/command/PullCommandTest_IO/pullHtml/input/translations/source-xliff_ja-JP.xliff
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:okp="okapi-framework:xliff-extensions" version="1.2"> | ||
<file original="" source-language="en" target-language="ja-JP" datatype="x-undefined"> | ||
<body> | ||
<trans-unit id="" resname="100 character description:" datatype="php"> | ||
<source>100 character description:</source> | ||
<target>100文字の説明:</target> | ||
</trans-unit> | ||
<trans-unit id="" resname="15 min" datatype="x-javascript+php"> | ||
<source>15 min</source> | ||
<target>15分</target> | ||
</trans-unit> | ||
<trans-unit id="" resname="1 day" datatype="x-javascript+php"> | ||
<source>1 day</source> | ||
<target>1日</target> | ||
</trans-unit> | ||
<trans-unit id="" resname="1 hour" datatype="x-javascript+php"> | ||
<source>1 hour</source> | ||
<target>1時間</target> | ||
</trans-unit> | ||
<trans-unit id="" resname="1 month" datatype="x-javascript+php"> | ||
<source>1 month</source> | ||
<target>1か月</target> | ||
</trans-unit> | ||
</body> | ||
</file> | ||
</xliff> |
1 change: 1 addition & 0 deletions
1
...om/box/l10n/mojito/cli/filefinder/FileFinderTest_IO/findHtml/input/source/filefinder.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
HELLO=Hello {0}! |
1 change: 1 addition & 0 deletions
1
...x/l10n/mojito/cli/filefinder/FileFinderTest_IO/findHtml/input/source/sub/filefinder2.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
HELLO=Hello {0}! |
1 change: 1 addition & 0 deletions
1
.../l10n/mojito/cli/filefinder/FileFinderTest_IO/findHtml/input/target/filefinder_fr-FR.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
HELLO=Bonjour {0}! |
1 change: 1 addition & 0 deletions
1
...box/l10n/mojito/cli/filefinder/FileFinderTest_IO/findHtml/input/target/filefinder_fr.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
HELLO=Bonjour {0}! |
Empty file.
1 change: 1 addition & 0 deletions
1
...10n/mojito/cli/filefinder/FileFinderTest_IO/findHtml/input/target/sub/filefinder2_fr.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
HELLO=Bonjour {0}! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.