As we intimated earlier, using PHP gettext is a good framework to use regarding writing your own serverside language translation functionality, but the โgruntworkโ is there ahead of you maintaining those [domain].po (Poedit) files. And so, improving on yesterdayโs AlmaLinux PHP Gettext Your Own Translation Tutorial โฆ
- Why donโt we back up an โinsufficient dataโ or โunknownโ translation ask from a user, now that they can enter their own words/phrases, by presenting a popup window Google Translate window as a backup?
- Why donโt we set up a system to follow up on moderations being attended to and accepted by administrative overseers, by adding those words/phrases accepted โฆ
<?php
$lastfile="";
if (file_exists('/tmp/get_text_moderation.txt')) {
$lines=explode("\n", file_get_contents('/tmp/get_text_moderation.txt'));
for ($ilines=0; $ilines<sizeof($lines); $ilines++) {
if (strpos($lines[$ilines], DIRECTORY_SEPARATOR . 'LC_MESSAGES' . DIRECTORY_SEPARATOR) !== false) {
$lastfile=$lines[$ilines];
} else if (strpos($lines[$ilines], ' msgid ') !== false && strpos($lines[$ilines], '_await') !== false) {
if (strpos(file_get_contents($lastfile), " msgid " . explode('_await', explode(' msgid ', $lines[$ilines])[1])[0] . '"' ) !== false) {
$wordopt.="<option value='" . explode('_await', explode(' msgid "', $lines[$ilines])[1])[0] . "'>" . explode('_await', explode(' msgid "', $lines[$ilines])[1])[0] . "</option>" . "\n";
}
}
}
}
?>
โฆ through to the Words/Phrases dropdown, in the web application?
Well?! Huh?!
We think so, and you can see this in action with thechanged get_textphp PHP Gettext Using web application you can also try below.
We hope you like it!
Previous relevant AlmaLinux PHP Gettext Your Own Translation Tutorial is shown below.
To open up yesterdayโs AlmaLinux PHP Gettext Translation Tutorialโs PHP Gettext Using web application to the possibility of โฆ
- user supplying a new locale into the mix โฆ and โฆ
- user supplying their own English to โTheir Newly Introduced Localeโ word/phrase translation
โฆ is fine and good in principle, but needs moderation, and that requires a deal of thinking. But then we thought, as far as moderation goes, why donโt we โฆ
- add to the [domain].po relevant [domain].po msgid entry a suffix that goes โฆ
_await_moderation_[IPaddressBasedStringWebBrowserBrandSpecific]
โฆ allowing the creator of the translation see their translation echoed back to them, but other people see no translation should they ask for the same translation conditions. That means if someone is not using the web application properly, only they, or people looking over their shoulder, see their own translation ideas happening ahead of a moderator stripping out from the msgid string any suffix like above if that moderator determines it is a genuine translation data item, in which case from then on all users see that translation suggestion come into โlive playโ.
See how we did this with thechanged get_textphp PHP Gettext Using web application you can also try below.
Previous relevant AlmaLinux PHP Gettext Translation Tutorial is shown below.
With our changeover to โฆ
- AlmaLinux Apache/PHP/MySql web hosting โฆ using โฆ
- PHP version with an 8 starting it
โฆ it is time to revisit the PHP gettext (Human Language Translation) module, that had us reach an install situation which looked like โฆ
# dnf list *get*text*
Last metadata expiration check: 1:51:10 ago on Wed 28 Aug 2024 11:45:24 AM AWST.
Installed Packages
ea-php80-php-gettext.x86_64 8.0.30-4.4.8.cpanel @EA4-c9
ea-php80-php-gettext-debuginfo.x86_64 8.0.28-1.1.29.cpanel @EA4-c9
ea-php81-php-gettext.x86_64 8.1.29-1.2.1.cpanel @EA4-c9
ea-php81-php-gettext-debuginfo.x86_64 8.1.19-2.2.1.cpanel @EA4-c9
ea-php82-php-gettext.x86_64 8.2.22-1.2.1.cpanel @EA4-c9
ea-php82-php-gettext-debuginfo.x86_64 8.2.6-2.2.1.cpanel @EA4-c9
ea-php83-php-gettext.x86_64 8.3.10-1.2.1.cpanel @EA4-c9
gettext.x86_64 0.21-8.el9 @baseos
gettext-common-devel.noarch 0.21-8.el9 @appstream
gettext-devel.x86_64 0.21-8.el9 @appstream
gettext-libs.x86_64 0.21-8.el9 @baseos
Available Packages
gettext-devel.i686 0.21-8.el9 appstream
gettext-libs.i686 0.21-8.el9 baseos
mingw32-gettext.noarch 0.21-5.el9 crb
mingw32-gettext-static.noarch 0.21-5.el9 crb
mingw64-gettext.noarch 0.21-5.el9 crb
mingw64-gettext-static.noarch 0.21-5.el9 crb
ocaml-gettext.x86_64 0.4.2-6.el9 crb
ocaml-gettext-devel.x86_64 0.4.2-6.el9 crb
perl-Locale-gettext.x86_64 1.07-21.el9 crb
python3-setuptools-gettext.noarch 0.1.3-2.el9 epel
โฆ (and a โฆ
dnf install glibc-all-langpacks
โฆ to install more locales on AlmaLinux web server) โฆ which you can see happening with todayโs animated GIF tutorial presentation, as we got somewhere (albeit, after half a day of struggle (getting fromyears back to โgetting thereโ, involving three โexitโ code snippet struggles (only the top one working)), which ended when reading brice/axice/beโs blurb on the PHP setlocale advising webpage, thanks for the brilliance) with gettext.Do not think of gettext as some miracle panacea for a language translation issue. It is just a good framework to use, but you still have to do the bulk of the โhard yardsโ โฆ
- creating [domain].po (Poedit) input files where msgid strings have translate from strings and msgstr strings have translate to strings relevant to your language locale (eg. de_DE for German) โฆ
- convert these to [domain].mo via โฆ
msgfmt [domain].po -o [domain].mo
- for each relevant locale โฆ you can check for relevance of via โฆ
locale -a
โฆ checking
โฆ with gettingthe breakthrough get_textphp PHP Gettext Using web application that harnessed some of the .po to .mo work we did when we presented the previous Yahoo YQL JSON Thesaurus Gettext Translation Tutorial, the results of which are reflected in the web application below โฆ
Previous relevant Yahoo YQL JSON Thesaurus Gettext Translation Tutorial is shown below.
Recently we talked about PHP methods to facilitate (language) internationalization via the โgettextโ Human Language and Character Encoding Support module with the PHP Gettext Internationalization Primer Tutorial.
Yesterdayโs Yahoo YQL Web Service JSON Thesaurus Tutorial as shown below, is a good candidate for โgettextโ internationalization, and we show the files necessary to oversee yesterdayโs HTML and Javascript with a layer of PHP to achieve it. We test this on our local MAMP local web server, where โgettextโ is enabled (unfortunately, this is not the case with the rjmprogramming.com.au domain, so today, we only have source code rather than an additional live run โฆ for that you can watch a video playing of a MAMP session using it here).
Now this additional internationalization concerns the โฆ
- language of the wording on the screen, and in error messages and titles
- starting of an execution in the same language as last used โฆ we use PHP methods, but you could also use Cookies for this idea
The downloadable PHP Ajax_yql_thesaurusphp (we show here the changes to it from yesterdayโs HTML at Ajax_yql_thesaurusphp) calls on localizationphp.
Sessions using Poedit (for our Mac laptop) resulted in the necessary translation *.po files (compiled into *.mo) โฆ
โฆ the languages of the YQL web service of the data emanating from its links to the altervista thesaurus web service database with Yahoo YQL website โฆ thanks. For the altervista thesaurus database usage it is best to request a key for your web service queries. You fill in a word (or two, or three) of interest to search for like-minded words.
Leave aside lots of time and/or
manperson power for the translation work. Hope this helps you out.
Previous relevant Yahoo YQL JSON Thesaurus and Translation Tutorial is shown below.
Language teachers will sometimes resort to an immersion method, in the classroom, where the only language allowed to be spoken is the language being learnt, often the second language for the student who is being taught. ESL teachers face this decision sometimes. We read an interesting article on the subject here, and decided to use our Pros and Cons web application to create our own view of the importance of the excellent points talked about in that article, as you can see with our report โฆ
Then there are degrees of โimmersionโ, as well, with questions such as whether you allow the use of paper (or electronic) dictionaries and translators. Think there is a lot of agreement that the best language learning happens with some degree of context and use of realia to help the student envisage the situations in which that vocabulary might be encountered. However, with written work or independent study, and even in the classroom a (web application) tool to help the learner with a difficult word could help, and so weโve extended the functionality of the previous Yahoo YQL Web Service JSON Thesaurus Tutorial as shown below, by offering the chance for the native language be used to translate the word, and offer a list of thesaurus word lists of the language they are learning out of the list of languages below โฆ
Read more about this below as well, but this tutorial uses a YQL web service into the data emanating from its links to the altervista thesaurus web service database with Yahoo YQL website โฆ thanks. For the altervista thesaurus database usage it is best to request a key for your web service queries. You fill in a word (or two, or three) of interest to search for like-minded words.
We found useful, and thank, for this extra functionality, the tremendous MyMemory API resource.
The downloadable HTML source code for todayโs tutorial you could call Ajax_yql_thesaurushtml (changed as per Ajax_yql_thesaurushtml) calls on the PHP yql_thesaurusphp (changed as per yql_thesaurusphp).
Try a liverun yourself and hope this sparks an idea or two for you.
Previous relevant Yahoo YQL Web Service JSON Thesaurus Tutorial is shown below.
Here is a tutorial that might be re-introducing you to the Yahoo Web Services called YQL, building on previous ones here at this blog. The name is the way it is because it simplified the API aspects of its functionality for the developer to concentrate on SQL, and Iโm really supportive of this concept. You donโt have to output in JSON, as other data forms like XML are acceptable. Letโs see what Wikipedia says about YQL below.
Yahoo! Query Language (YQL) Gumtree Advertisementusing Android Phone Photos Tutorialis an SQL-like query language created by Yahoo! as part of their Developer Network. YQL is designed to retrieve and manipulate data from APIs through a single Web interface, thus allowing mashups that enable developers to create their own applications.[1]
Initially launched in October 2008 with access to Yahoo APIs,[2] February 2009 saw the addition of open data tables from third parties such as Google Reader, the Guardian, and The New York Times.[3] Some of these APIs still require an API key to access them. On April 29th of 2009, Yahoo introduced the capability to execute the tables of data built through YQL using JavaScript run on the companyโs servers for free.[3]
So this tutorial uses a YQL web service into the data emanating from its links to the altervista thesaurus web service database with Yahoo YQL website โฆ thanks. For the altervista thesaurus database usage it is best to request a key for your web service queries. You fill in a word (or two, or three) of interest to search for like-minded words.
And what is a thesaurus? Read what Wikipedia says here but, basically, it can be thought of as a repository of a languageโs list of words of a similar meaning to the word of your interest. It is a great tool for people learning a language foreign to them, especially regarding their vocabulary.
The two big PHP functions of use (as distinct from an Ajax approach, requiring no PHP โฆ read on) for this are:
- file_get_contents
- json_decode โฆ when there is a data structure of any complexity, this function is highly recommended, but for todayโs tutorial we do not use it, and take the opportunity to show you a solution using Ajax that requires no PHP โฆ link to some downloadable Ajax inspired HTML programming source code which you may want to rename to Ajax_yql_thesaurushtml which changes from the HTML supervising PHP approach as per Ajax_yql_thesaurushtml (and then there is an Ajaxlive run)
Good links for information regarding this tutorial (thanks) are:
- YQL Two Minute Tutorial from Yahoo
- Yahoo! Query Language from Wikipedia, as per quote above
- YQL Home Page from Yahoo
- YQL thesaurus help from Yahoo
- YQL JSON Parsing Help from YQL forum
Another tool you should have in your armoury for jobs like this is the online JSON validator here. A generic JSON approach to issues could be:
- Type the URL you were given into a web browser address bar and have a look at it
- Type the URL you were given into //jsonlint.com/ and have it validated
- Understand in your own mind what would be different about 1. to make it suitable
- Incorporate findings of 3. into massaging of data between file_get_contents and json_decode
Here is a link to some downloadable HTML programming source code which you may want to rename to yql_thesaurushtml which calls some downloadable PHP programming source code which you may want to rename to yql_thesaurusphp (and then there is a PHPlive run).
We thank the following free online dictionaries โฆ
Stay tuned for an interesting blog posting tomorrow which combines the new thesaurus functionality of todayโs contribution, along with the functionality โsmartsโ of yesterdayโs PHP/CSS Sentence Auxiliary Verb Game Tutorial.
Stop Press
As of 14th May 2015 a blog posting called HTML/Javascript Homonyms Game Tutorial inspired a โtweakโ to the arrangement above such that a call of the web application above such as Sense of Humour will cause the display of a lookup during the โonloadโ event, as required.
If this was interesting you may be interested in this too.
If this was interesting you may be interested in this too.
If this was interesting you may be interested in this too.
If this was interesting you may be interested in this too.
If this was interesting you may be interested in this too.
If this was interesting you may be interested in this too.