Automatic language tagging with Polylang in WordPress

I use the Polylang plugin for the multi-language capabilities of the sites written on WordPress. One feature that I implemented and find extremely useful is the automatic tagging of the posts with a language tag (like “en”, “ru”, etc.) when the post is saved. The code that goes into the functions.php file of the theme is as follows:

function tigra_add_polylang_language_tag( $post_id ) {
        global $polylang;
        if (isset($polylang) ) {
                if ( !$polylang->model->get_post_language($post_id) ) {
                        $polylang->model->set_post_language($post_id, pll_default_language());
                }
                $post_lang = $polylang->model->get_post_language($post_id);
                $languages = $polylang->model->get_languages_list(array('fields' => 'slug'));
                $post_tags = get_the_tags($post_id);
                $post_tags = wp_list_pluck($post_tags, 'name');
                $post_tags = array_diff($post_tags, $languages);
                if ( empty($post_tags) ) {
                        $post_tags = array();
                }
                array_push($post_tags, $post_lang->slug);
                wp_set_post_tags($post_id, $post_tags);
        }
}
add_action( 'save_post', 'tigra_add_polylang_language_tag' );

The code verifies that the default language is set (as I heard some reports that the mobile applications sometimes manage to bypass the Polylang capabilities) and sets it if necessary. Then, it extracts all tags from the post, wipes all supported (selected in Polylang configuration) language tags and adds a single tag corresponding to the language of the post.

This procedure makes sure that the language tag is always present and that the old tag is wiped when you change the language of the post. Now you can retrieve the posts, sort or do other manipulations based on the tag.

Big kudos to Chouby for the plugin and the help with code.… -->

continue reading →

Privacy, Democracy and Big Data

I read recently two very interesting articles that discuss in depth the current problems with the internet, privacy and democracy implications. I highly recommend reading both:

  • The Real Privacy Problem
  • Three Paradoxes of Big Data

The Internet and the related technologies erode the very fabric of society. They do so quietly, surreptitiously, in little steps. As usual, do not blame the tool, blame those that use it for evil. Although some tools better not have existed in the first place, I feel.… -->

continue reading →

Facial recognition for surveillance at large

There is an interesting article about face recognition cameras and software at TechRepublic that cites a few interesting projects and makes a good point about the advances of the technology.

I talked to a few people that know well the camera systems in London and I understand that they now can track anyone around the city automatically. The technology that we think is from fiction books is actually already there. There is no need to think whether it is possible or not, it is. The only problem for wide-spread surveillance is that the cameras have to be installed…

I read a wonderful book “Rule 34” by Charles Stross recently that I can wholeheartedly recommend. The book’s action is set into the future but that is the future that has all the technology of today, simply deployed overall. It is not such a far-fetched story any more than the article linked above.

The spread of surveillance calls to life such things like counter surveillance clothing fashion. I think when it is in the fashion, it is not new any longer, is it?… -->

continue reading →

The Origins of German

I had a long chat with my German teacher the other day about language history and evolution. She mentioned something astounding: the first book, on which the German language is based, that actually created the grammar of the language, was the work of Martin Luther. But if I am not mistaken, that was in the 16th century. So the German language is only about 500 years old. I wonder if the situation is the same then with all European languages…… -->

continue reading →

MBTI is dead? Long live Socionics!

I accidentally stumbled on an article about the death of MBTI yesterday. Strangely, it never occurred to me that there would be a wide audience interest in things like typologies in general and MBTI in particular. I always thought these were fairly specialized subjects only interesting for a minority of people. Since you seem to be interested, I present to you Socionics.

It all originated some time in the previous century with the works of Karl Gustav Jung, a Swiss psychiatrist. His work was later built upon to create MBTI and later corrected and extended by people like Aušra Augustinavičiūtė, Gregory Reinin and Igor Kalinauskas to become Socionics. Nowadays Socionics is a young but fairly popular in narrow circles direction of social psychology. Actually, there are still raging debates on the subject of “where it all belongs”.

Socionics works with dichotomies of information processing functions and therefore describes how the given person filters and processes the information coming from outside, bases the decisions and outputs the information into the outside world. So Socionics is really a study in information metabolism of the psyche.

Given that, we can roughly say that a human being has some basic instincts at the base of its decision making, then there is the distinction between male and female, on top of that sits the information metabolism and that is all wrapped into a personality. The type of information metabolism determines those deep motivations inside the psyche that cause us to take many of our decisions. One has to note, of course, that different motives deep inside may cause nearly the same actions in different individuals. Different personalities may cause differentiation in actions based on the same motives.

Determining the type of information metabolism, or the socionic type, of a person is a task of uncovering those deep seated motivations that demonstrate how the given person processes the information. Tests for MBTI fail here because they try to correlate the behavior directly to the type but we see that the behavior is controlled by the personality. The type of information metabolism can be seen clearly when the practitioner concentrates on the motivations underlying the behavior. Unfortunately, the development of tests in this direction is far from mature yet and best results are based on the expert… -->

continue reading →

Quality of teaching

How would one go about determining a quality of teaching? Or, rather, the quality of a teacher? Say, you have a teacher in your school, you want to know if he is good or not, so you can replace him or keep him. What do you do?

It seems a difficult question and it seems that judging the quality of work the teacher does is really hard, especially if harmonious personality development is much higher on your agenda than getting end-year tests passed. Some thoughts on the matter include:

  • Participating in a class (what if you do not understand the subject completely and cannot judge?)
  • Reading through class plans, trying to figure how much effort the teacher puts into preparation
  • Interviewing pupils or students for both their feeling and their understanding of the subject
  • Setting independent tests (problems with tests are huge and numerous, so this may not quite work)

But there must be already some methods that work… Aren’t there?… -->

continue reading →

Global survillance economic results

An article in The Morning Call talks about economic impact of the NSA surveillance, but limits the discussion to its area of interest – the US companies, while making me think about the rest of the world:

Worldwide spending on the cloud is expected to double over the next three years to more than $200 billion. U.S. firms have been leaders in developing the technology. According to a new report from the Information Technology & Innovation Foundation, however, global worries about NSA surveillance are likely to reduce U.S. market share.

The report’s admittedly loose estimate is that U.S. cloud-computing firms will lose $21 billion to $35 billion in revenue between now and 2016. According to the report, some 10 percent of non-U.S. members of the Cloud Security Alliance said they’ve canceled a project with a U.S. company since the disclosure of the NSA’s surveillance. In addition, 56 percent indicated “that they would be less likely to use a U.S.-based cloud computing service.”

Interestingly, this does not only apply to the US economy. There are companies everywhere that would rather prefer not to be monitored. That would rather prefer to go about their business without this stranger looking over their shoulder day and night. What will happen?

I think we may be facing a new arms race soon. The businesses with money were not all that interested in keeping things private until now. Now they will likely invest in tools for privacy and the tools will get better. And so off we go, there will be demand for privacy from the, ahem, private sector and the demand for surveillance from the government sector. Big money to be made.

Just wondering… will the common citizen become “collateral damage” in this war?… -->

continue reading →