Cakephp website with English and Arabic support for the same database - cakephp

Im building a website in CakePHP 1.3. My requirement is to have a website with arabic and english support. I want that if a user is entering the information in arabic so when the english user sees the same information it should be in english and vice versa.
As far as localing the labels ive done that using po files. Its pretty straight forward.
But for the database im using the Cakephp's built-in Translate Behaviour. But it again doesn't translate anything and creates another copy of the data with the current locale that is in use.
Please help me in which direction i should move.
I want to know the best practices that should be followed for this kind of scenario.
May be translating db values is not the best solution and should save the values as in whatever language they are coming.
Any help and suggestions would be highly appreciated.

It isn't actually possible to have CakePHP automatically translate data that is entered.
The Translate Behavior allows you to enter the same content in multiple languages and then retrieve the appropriate language from the database, based on the language that you currently have set in your config. It doesn't actually translate anything for you.
Theoretically, you could add a function to the Model::beforeSave() callback that would submit the Arabic text to a service like Google Translate and then save both Arabic and English versions to their appropriate tables, but the results won't necessarily be very good. As #deceze said in his comment to your question, machine translation is a hard problem.

Related

Google translate API phrase into every language using classic ASP

Good morning everyone,
I have something [maybe not so] unique which I want to do which is translate a simple phrase like "Hello" into every language available under Google Translate API. I want to basically capture the results and store it into a SQL Server database.
In the past, I have written bulk geocoding processes using ASP and that worked well, and I am thinking that I can do the same with the translate API using a querystring. However, there are really no great examples of it.
I am about to drop the languages and their codes into a table so that I can just loop through things, and then use a JSON parser since I am not using the latest version of SQL Server. I have done crazy ASP SOAP implementation in the past which required authentication twice, but am thinking that this can be done differently.
I am just figuring that someone else out here might have had to slay this dragon before and any and all tips would be greatly appreciated.
Thanks
The Translation API only allows for one target language per request. Unfortunately, for your use case you would have to loop through the desired languages and send a separate request for each.

Saving code in database, what are pitfall I should be careful about

I am designing a system which takes user submitted code and saves it in database. Code can be in any language, ruby, python, elixir, javascript, etc. There's no restriction on language. Code saved in database is never meant to be run. It will be displayed in blog article or converted into file for download. Similar example might be GitHub gist or Cacher, both takes user submitted code and displays on website.
How do I make sure User submitted code is sanitised and secure to be displayed on webpage with code highlighter?
What processing do I need to do on code such that I can safely display it? I don't want to impose strict restrictions on users.
Any gotcha I need to be aware?
Any idea how those website implement this feature?
I am using Elixir and Phoenix framework. Is there any pitfalls I should be careful about? I am thinking of using Phoenix.HTML module to escape codes. I just wanna be sure that my approach doesn't have known loop holes.
I think you are looking for this https://www.owasp.org/index.php/XSS_(Cross_Site_Scripting)_Prevention_Cheat_Sheet

Wordpress stores user nickname only if it is in English

I have a problem in my Wordpress. if i save a user nickname with any language other than English, like Persian, it will store it as empty value in DB
And then the URLs won't work anymore. Is this a problem of mine or it's something global and it should be the way it is?!
if there is a solution for it, i will be thankful.
Maybe installing Wordpress in Farsi and having a language plugin of some sort will fix your issue as of stated in the official documentation.
https://codex.wordpress.org/Right-to-Left_Language_Support#Writing_a_Post_in_RTL_Language
This is also probably due to the tables not being set to support the language special encoding.

AngularJs database data internationalization

I´m developing a i18n AngularJS application. I would need to display the info in english and also spanish. I´m currently using ng-translate for static content and it´s really good. But I would need to translate some info coming from database, such as the typical dropdown (select field) with country names. Depending on the user language settings, there values in the combo should be displayed in english or spanish.
I don´t know what is the best architectural approach. I mean, I think in two first approaches:
1.1 I have a table in database with the countries in just one default language (english). When I get this list to display these values are dinamically translated somehow.
1.2 I have a table in db with so many columns as languages with the countries in different languages. When I get the list I use the language settings to get the right column.
I don´t know if there is any other approach. I like 1.1. But, I´m not sure if I can implement it and how. I also would need to display these values ordered.
UPDATE
To enrich the final solution. You can have a look at next post, related to how to design a multilingual database (design pattern).
http://cleancodedevelopment-qualityseal.blogspot.com.es/2013/06/translation-multilingualmultilanguage.html
I would tend to go with 1.2, as that way you are in control of the translations. Country names probably aren't going to be much of an issue, but if there is anything more complicated, like phrases and such, then I would definitely go with 1.2, as current translation software is likely to lose nuances in translation that could be important. 1.2 would probably also make sorting slightly easier.

Data source of English speech phrases

I am doing a research on developing a simulated environment for the students (who use English as second language) to practice English speaking.
In one part of my development, I need a data source which contains mostly using English speech phrases which are tagged against the real incident. As an exmaple,
“Ways to Apologise
Sorry.
I’m sorry.
I’m so sorry!
Sorry for your loss.”
I could find several sites which are providing this service http://edition.englishclub.com, but not a data source.
Has somebody used such a data source , which can be used like ‘wordnet’ ? If so please help me to carry on this forward. Otherwise I have to develop such a data source which I feel like reinventing the wheel.

Resources