-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
making the server side content l10n work.
- Loading branch information
Showing
19 changed files
with
224 additions
and
74 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
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
45 changes: 45 additions & 0 deletions
45
server/src/main/java/org/uiautomation/ios/server/application/ServerSideL10NDecorator.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,45 @@ | ||
package org.uiautomation.ios.server.application; | ||
|
||
import org.uiautomation.ios.UIAModels.predicate.Criteria; | ||
import org.uiautomation.ios.UIAModels.predicate.CriteriaDecorator; | ||
import org.uiautomation.ios.UIAModels.predicate.MatchingStrategy; | ||
import org.uiautomation.ios.UIAModels.predicate.PropertyEqualCriteria; | ||
import org.uiautomation.ios.exceptions.InvalidCriteriaException; | ||
|
||
public class ServerSideL10NDecorator implements CriteriaDecorator { | ||
|
||
private final IOSApplication app; | ||
|
||
public ServerSideL10NDecorator(IOSApplication app) { | ||
this.app = app; | ||
} | ||
|
||
@Override | ||
public void decorate(Criteria c) { | ||
if (!isElligible(c)) { | ||
return; | ||
} | ||
PropertyEqualCriteria criteria = (PropertyEqualCriteria) c; | ||
String oldValue = criteria.getValue(); | ||
LanguageDictionary dict = app.getDictionary(app.getCurrentLanguage()); | ||
String newValue = dict.getContentForKey(oldValue); | ||
if (newValue == null) { | ||
throw new InvalidCriteriaException("No entry for key " + oldValue + " in dictionary for " | ||
+ app.getCurrentLanguage()); | ||
} | ||
|
||
criteria.setValue(LanguageDictionary.getRegexPattern(newValue)); | ||
criteria.setStrategy(MatchingStrategy.regex); | ||
} | ||
|
||
|
||
private boolean isElligible(Criteria c) { | ||
if (c instanceof PropertyEqualCriteria) { | ||
PropertyEqualCriteria crit = (PropertyEqualCriteria) c; | ||
return crit.getMatchingStrategy() == MatchingStrategy.serverL10N; | ||
} | ||
return false; | ||
} | ||
|
||
|
||
} |
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
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.