-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix various issues with the Transliteration API (#742)
- Loading branch information
1 parent
930e502
commit 85cb8d3
Showing
3 changed files
with
9 additions
and
12 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,24 @@ | ||
<?php | ||
namespace Transvision; | ||
|
||
// Check that the class exists before trying to use it | ||
// Requires php-intl | ||
// Check that the class exists before using it. Requires the php-intl extension | ||
if (! class_exists('Transliterator')) { | ||
$request->error = 'Class Transliterator not available'; | ||
$json = $request->invalidAPICall(501); | ||
|
||
return; | ||
return $request->invalidAPICall(501); | ||
} | ||
|
||
switch ($request->parameters[2]) { | ||
case 'sr-Cyril': | ||
case 'sr-Cyrl': | ||
$transliterated_locale = 'Serbian-Latin/BGN'; | ||
break; | ||
|
||
default: | ||
$request->error = 'Wrong language'; | ||
$request->error = 'Wrong locale code'; | ||
|
||
return $request->invalidAPICall(501); | ||
return $request->invalidAPICall(); | ||
} | ||
|
||
$transliterator = \Transliterator::create($transliterated_locale); | ||
$transliterated_string = $transliterator->transliterate($request->parameters[3]); | ||
|
||
return $json = [$transliterator->transliterate(Utils::secureText($request->parameters[3]))]; | ||
return [$transliterator->transliterate(Utils::secureText($request->parameters[3]))]; |
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