Often we see code like this:
__( 'Daily Archives: %s', 'twentyeleven' ),
First argument is string to be translated, and the second is domain used.
What's the purpose of this? Why does it need to be translated? And what's the outcome of the translation?
This answer really should/could be a comment; all the information you need about WordPress Translations can be found in the codex, here.
What's the purpose of this?
Internationalization and localization are terms used to describe the effort to make WordPress available in languages other than English, for people from different locales, who use different dialects and local preferences.
Why it needs to be translated, and what is the outcome of the translation?
Reading the codex, and the above paragraph (from the codex), will answer this as well.
But there is no need to translate it, it just adds to the users benefit to have translation/localizations available because not everyone speaks the same language.
Many theme creators make it a standard practice to develop themes that are ready to be localized because it not only adds extra value to their theme, it is (relatively speaking) not that much extra work to do.
An added benefit is that you can easily change wording on your website without having to add or edit the code. Or you can easily do things like making your website in 'Pirate'-language on national pirate day. Or pull pranks on the 1st of April by removing all vowels or something like that. - All of which are just a 'creative' (not necessarily intended) uses of translations.
Related
There are a lot of plugins to translate Wordpress from e.g. English into German/French/Spanish etc.
But i am looking to achieve the opposite, i want to gather some international content and translate it automatically to English. Content will be added through WP All Import or through other import.
I will have the "international language code" per content available, so i could indicate the source language of the content.
I have reached out to several WP translation plugin developers, but they told me the plugin only work from one language to multiple others and not the other way around.
What would be the best way to get my Multilanguage content to English? I was thinking following options:
Have a custom extension to WPAI developed that translates on import, but the downside is that it is slow with higher volumes.
Perhaps it would be possible to have the content translated to English (if not available) when the page actually loads, and store the result in a column for future usage.
I don't know if above would be even possible, perhaps someone has some pointers on where i can search to find a solution for my case.
Have you tried the Loco translate plugin ? I know this looks like to be the opposite of what you are trying to do but this extension lets you select what theme, plugin and even specific strings you want to automaticaly translate. You can also add configuration files to translate anything on your website as you want.
Let me see if I understand correctly. You will have content in languages X, Y, Z (post in X, another post in Y, another in Z) and you want to separately translate each to English (E) like this?
X -> E
Y -> E
Z -> E
Or are you looking to somehow merge all the source languages into one (X,Y,Z -> E)?
If option 2 I have no idea how this would be done.
If option 1 then IMHO it doesn't matter from what and to what you want to translate. The question you need to answer is:
Which plugin(s) is(are) capable of automatically translating from all your source languages into English? For example here's a list of supported languages for WPML: https://ate.wpml.org/mt_langs
Once you import all the content into WordPress with the correct language codes which the translation plugin can recognize (to correctly perform machine translation), you will be able to translate each post/page into English using that plugin.
Wordpress's datamodel provides extensibility through it's "meta" tables (aka, wp_postmeta, wp_commentmeta, wp_usermeta). This name/value pair linking is extremely flexible and supported by Wordpress's API. All good reasons to celebrate it but it also can get quite non-performant if you have lots of extension attributes hanging off of your transactions. Let's say, for instance, that I have a Custom Post Type called "Blood Test" and I want it to be able to capture 30-40 different measurements coming out of the blood analysis. Is it practical to use this wp_postmeta joining for each test? Probably not.
I could go completely bespoke and build tables left and right but what I'm wondering is, is there not a way to at least build an "80/20 rule" and have a generic extension table that provides a static number of additional columns to put SQL-searchable attributes and then end with a column for a JSON object that would allow for non-SQL searchable attributes to extend to an almost unlimited amount? Something like what is diagrammed below:
I was thinking that by doing this one could also extend the Wordpress API so that most development could largely be ignorant of this structural difference. Something like this:
EXAMPLE OF REGISTRATION API:
$my_meta_ext = new WP_Meta_Extension( 'post' );
$my_meta_ext->add_tran_type( 'blood-measurement' , ( 'col1' => 'total-cholesterol' , 'col2' =>
'triglycerides', 'col3' => 'etc');
EXAMPLE OF USAGE API:
add_ext_meta ( $term_id, 'blood-measurement.total-cholesterol', $meta_value );
Ok, so here are my explicit questions for the group:
Does this make sense? Do you see value in this? Does anything like this already exist in a 'plugin' form (or otherwise)?
If you were to use one extension table across all types (aka, posts, comments, users, etc.) would you be able to build an index in mySQL that was efficient? Is it better just to have a table per type?
Does anyone have any metrics -- even if they're not fully proven out -- on when the default wordpress extension model starts to degrade in performance?
If you've done something like this already ... any key lessons learned when extending the model? How complicated of a task is this?
I brought this topic into a specialist WordPress working group in London and while we didn't arrive on an answer there was pretty clear agreement that this type of solution would be highly valuable. Furthermore, I have decided to start a GIT repository with the intent of developing a plugin to address this (hopefully with the generous support of the group in London or any of you who are reading this and feel you could help).
The repository can be found here:
https://bitbucket.org/ksnyder/wp-database-extension/
Please understand that at this moment there is really just an idea, a high-level design, an interface spec, but no real code. That will change of course and it will change more quickly if you're willing to help us with this endeavour (mind you I have no personal experience running distributed development but you have to learn somewhere).
I'm considering which software to use for a blog that I would like to install in a personal home server (synology). Here are my requirements:
Language management: I'll be writing in different languages, and some entries would be translated in different languages, not always the same. Blog readers should be able to select which languages they can/wish to read. For instance, if they chose English, then all entries which have English translation would appear in English, the remaining appearing in whatever language they were written, or not at all.
RSS customization: the blog will broach different subjects. I would like the users to be able to customize a RSS syndication which corresponds to their interests, so that the sigal to noise ration in their RSS readers remains bearable. This should probably work with a "Categoriy" or "Tag" system.
sub-blogs: I would like to have sub-blogs with their own url, which would present a subset of the blog entries. For instance my blog could deal with politics, sports, and myLife, and I could produce the following blog urls: blog.mydomain.tld (shows everything), opinions.mydomain.tld (shows only the politics related posts), sports.mydomain.tld (all entries dedicated to sports). I would also like to theme differently those sub-blogs (i.e. a ball picture for sports.mydomain.tld, etc).
modular privacy: my intended audience is heterogeneous (family, sets of friends, the internet), and I would like to be able to limit access to certain entries to different subsets of users. To me, the most obvious way to do this would be to define users with a login and password. I would then pool them into groups, and define for each entry if it is private, and if so which groups can read it. I do not necessarily want to share the same things between my neighbors and my school friends.
That also brings the issue of RSS syndication: either each user would have its how RSS thread, or then RSS could be category specific and the private entries would appear without content. Perhaps other possibilities exist.
These set of features are quite specific. I was thinking of using a blog software to implement them, but perhaps I'm thinking this wrong and I should use a CMS or even a framework?
Another point is that this is done for "fun", and although I can program (python, etc), this is not my day job, so it should not require expert level skills or full time investment to implement. A solution which involves me developing a whole new blog application is not adapted to my constraints.
EDIT
OpenID: I like the Stack Overflow login system (check this screen capture of it), because most readers already have an OpenID, and in any case do not need to create a specific one for my blog. The system I would use should be capable of using the OpenID method of authentication
I don't know what is the best translation software around.
But I only use a Babylon Software as an Online Translator too.
You can find it at http://babylon.depapaz.com
Till now, I only use this program for my online translation software.
And I think is good enough as a Translation Software.
I'm adding additional languages to a Drupal site that I'm building.
Getting the translation of content working is fairly easy using the Internationalisation module.
Yet, simple things such as date strings, i.e. day, month and year aren't translated.
I would expect simple things like this to be some of the first things to be translated.
Am I missing something?
For text to be translated, each module needs to pass display text through a specific function (named 't()') which allows the text to be translatable.
It's likely that some module writers are better at doing this consistently than others.
I found the solution to this in the end.
It came down to knowing what to search for in the translate interface admin section.
I was looking to translate month names into different languages and so search for strings matching 'November'. This always came up with nothing.
It truned out that I need to search for 'month'. This then allowed my to add translations for all of the month names and also other date related translations.
Very frustrating the effort required to find that out!
How should I store (and present) the text on a website intended for worldwide use, with several languages? The content is mostly in the form of 500+ word articles, although I will need to translate tiny snippets of text on each page too (such as "print this article" or "back to menu").
I know there are several CMS packages that handle multiple languages, but I have to integrate with our existing ASP systems too, so I am ignoring such solutions.
One concern I have is that Google should be able to find the pages, even for foreign users. I am less concerned about issues with processing dates and currencies.
I worry that, left to my own devices, I will invent a way of doing this which work, but eventually lead to disaster! I want to know what professional solutions you have actually used on real projects, not untried ideas! Thanks very much.
I looked at RESX files, but felt they were unsuitable for all but the most trivial translation solutions (I will elaborate if anyone wants to know).
Google will help me with translating the text, but not storing/presenting it.
Has anyone worked on a multi-language project that relied on their own code for presentation?
Any thoughts on serving up content in the following ways, and which is best?
http://www.website.com/text/view.asp?id=12345&lang=fr
http://www.website.com/text/12345/bonjour_mes_amis.htm
http://fr.website.com/text/12345
(these are not real URLs, i was just showing examples)
Firstly put all code for all languages under one domain - it will help your google-rank.
We have a fully multi-lingual system, with localisations stored in a database but cached with the web application.
Wherever we want a localisation to appear we use:
<%$ Resources: LanguageProvider, Path/To/Localisation %>
Then in our web.config:
<globalization resourceProviderFactoryType="FactoryClassName, AssemblyName"/>
FactoryClassName then implements ResourceProviderFactory to provide the actual dynamic functionality. Localisations are stored in the DB with a string key "Path/To/Localisation"
It is important to cache the localised values - you don't want to have lots of DB lookups on each page, and we cache thousands of localised strings with no performance issues.
Use the user's current browser localisation to choose what language to serve up.
You might want to check GNU Gettext project out - at least something to start with.
Edited to add info about projects:
I've worked on several multilingual projects using Gettext technology in different technologies, including C++/MFC and J2EE/JSP, and it worked all fine. However, you need to write/find your own code to display the localized data of course.
If you are using .Net, I would recommend going with one or more resource files (.resx). There is plenty of documentation on this on MSDN.
As with most general programming questions, it depends on your needs.
For static text, I would use RESX files. For me, as .Net programmer, they are easy to use and the .Net Framework has good support for them.
For any dynamic text, I tend to store such information in the database, especially if the site maintainer is going to be a non-developer. In the past I've used two approaches, adding a language column and creating different entries for the different languages or creating a separate table to store the language specific text.
The table for the first approach might look something like this:
Article Id | Language Id | Language Specific Article Text | Created By | Created Date
This works for situations where you can create different entries for a given article and you don't need to keep any data associated with these different entries in sync (such as an Updated timestamp).
The other approach is to have two separate tables, one for non-language specific text (id, created date, created user, updated date, etc) and another table containing the language specific text. So the tables might look something like this:
First Table: Article Id | Created By | Created Date | Updated By | Updated Date
Second Table: Article Id | Language Id | Language Specific Article Text
For me, the question comes down to updating the non-language dependent data. If you are updating that data then I would lean towards the second approach, otherwise I would go with the first approach as I view that as simpler (can't forget the KISS principle).
If you're just worried about the article content being translated, and do not need a fully integrated option, I have used google translation in the past and it works great on a smaller scale.
Wonderful question.
I solved this problem for the website I made (link in my profile) with a homemade Python 3 script that translates the general template on the fly and inserts a specific content page from a language requested (or guessed by Apache from Accept-Language).
It was fun since I got to learn Python and write my own mini-library for creating content pages. One downside was that our hosting didn't have Python 3, but I made my script generate static HTML (the original one was examining User-agent) and then upload it to server. That works so far and making a new language version of the site is now a breeze :)
The biggest downside of this method is that it is time-consuming to write things from scratch. So if you want, drop me line and I'll help you use my script :)
As for the URL format, I use site.com/content/example.fr since this allows Apache to perform language negotiation in case somebody asks for /content/example and has a browser tell that it likes French language. When you do this Apache also adds .html or whatever as a bonus.
So when a request is for example and I have files
example.fr
example.en
example.vi
Apache will automatically proceed with example.vi for a person with Vietnamese-configured browser or example.en for a person with German-configured browser. Pretty useful.