Sunday, January 12, 2020

Wordpress DIVI Theme internationalization - evaluation and issues

Website localization is better done when websites are internationalized. Wordpress uses the GNU Translation Project gettext utility for internationalization (i18n) and at the time of this writing most professional plugins and themes use gettext .po files to define localization (l10n) strings (AKA localizable text) in plain text and .mo files that are a machine representation of the .po files to aid gettext with the optimal replacement of the strings.

The main issue with current plugins and themes is that they fail to localize all their pieces driving most developers to look for alternatives that would instead push them to duplicate websites. But we, as software engineers, know that most of the time reusability is king and to achieve it we need to get back to the roots: be simple (use gettext) and precise (help the theme or plugin author to internationalize).

Here is what I patched this weekend in the Divi plugin. I hope the Divi team will read this and incorporate these fixes (or alike). There are so many people looking for answers to these problems and at the end the solution is not simple for them (as they have to go out there and purchase yet another plugin) neither precise (as no patch is offered to work with these themes and plugins as they are without the need to add a Wordpress translation plugin).

I am all for the use of translation plugins but one size does not fit all and being able to control your own destiny is sometimes (arguably all times) very important.

For those Wordpress Divi users that want to control their own destiny here are the patches needed to make some of the most common Wordpress Divi modules fully localized:
  1. Divi Tabs module: The tab title is not internationalized. To fix it file includes/builder/module/Tabs.php needs to use esc_html__ on each value of each $tab_title array inside function get_tabs_nav()
    ...
     public function get_tabs_nav() {
      global $et_pb_tab_titles;
      global $et_pb_tab_classes;
    
      $tabs = '';
    
      $i = 0;
      if ( ! empty( $et_pb_tab_titles ) ) {
       foreach ( $et_pb_tab_titles as $tab_title ){
                    // The below block is necessary to internationalize the tab titles
                    foreach ($tab_title as $key=>&$value){
                      $value = esc_html__($value, 'et_builder');
                    }
                    // End of tab titles internationalization block
                    unset($value);
    ...
    
  2. Divi Button Module: The button title is not internationalized. To fix it, file includes/builder/module/Button.php, function render() should assign to button_text the i18n value using the esc_html__() function:
    ...
      // Render Button
      $button = $this->render_button( array(
       'button_id'           => $this->module_id( false ),
       'button_classname'    => explode( ' ', $this->module_classname( $render_slug ) ),
       'button_custom'       => $button_custom,
       'button_rel'          => $button_rel,
       'button_text'         => esc_html__( $button_text, 'et_builder' ), // button i18n
    ...
    
  3. Divi Blurb module: The Blurb title is not internationalized. To fix it, file includes/builder/module/Blurb.php, function render() should assign to the blurb title the i18n value using the esc_html__() function (and others because for this case the actual plain text title is a protected member of an object):
    ...  
      if ( '' !== $title ) {
       $title = sprintf(
        '<%1$s class="et_pb_module_header">%2$s',
        et_pb_process_header_level( $header_level, 'h4' ),
        et_core_esc_previously( $title )
       );
                            // starts blurb i18n patch
                            $plain_source_title = strip_tags( $title );
                            $plain_target_title = esc_html__($plain_source_title, 'et_builder');
                            $title = str_replace ($plain_source_title, $plain_target_title, $title);
                            // ends blurb i18n patch
      }
    ...
    
  4. Divi Post Title module: The Post Title title is not internationalized. To fix it, file includes/builder/module/PortTitle.php, function render() should assign to $post_title the i18n value using the esc_html__() function:
    ...
      if ( $multi_view->has_value( 'title', 'on' ) ) {
       if ( is_et_pb_preview() && isset( $_POST['post_title'] ) && wp_verify_nonce( $_POST['et_pb_preview_nonce'], 'et_pb_preview_nonce' ) ) {
        $post_title = sanitize_text_field( wp_unslash( $_POST['post_title'] ) );
       } else {
        $post_title = esc_html( et_builder_get_current_title() );
       }
                    $post_title = esc_html__($post_title, 'et_builder'); // post title i18n fix
    ...
    
    BTW if you are looking to translate your website, internationalized or not, and do not have the workforce to do it (engineers, linguists etc) I strongly recommend Protranslating. Not only you will get full support from very talented people, but you will be in very good hands from a security and privacy standpoint.

    Full Disclosure: I work for Protranslating but the opinions expressed in all of my posts are not necessarily those of my employer.

Saturday, November 16, 2019

Find what package contains a command in Ubuntu Linux

Let's find what package has the traceroute command to learn by example:
apt install apt-file
apt-file update
apt-file search traceroute

Tuesday, November 12, 2019

docker.io unauthorized: incorrect username or password

Problem: I got the below issue when trying to execute "docker run -i -t ubuntu:18.04 /bin/bash":
docker: Error response from daemon: Get https://registry-1.docker.io/v2/library/ubuntu/manifests/18.04: unauthorized: incorrect username or password. See 'docker run --help'.
Resolution:
docker logout
docker run hello-world

Saturday, October 12, 2019

Switch Android accounts to access a different country play store



If you travel abroad, you might want to install and/or use applications that are not allowed from outside the country you are visiting.

Here is the simplest way to go around this issue:
  1. If your email is sample@gmail.com create a new gmail for the country you will be visiting, for example sample.es@gmail.com if you are visiting Spain.
  2. In your Android settings, add a new account using that newly created email.
  3. In your Android device, open the Play Store application and switch to that account. Search for the app to be installed and it should be available.
  4. If you need to use an app only available in a country from a different country, you will also need a VPN app installed in your Android so that you can switch the country from where the device presents itself as running in.
From now on you can switch accounts in your Android Play Store application to use applications only available in the specific country you are visiting.

Friday, July 26, 2019

Happy #SysAdminDay

What would your life be like without a #Sysadmin?

Sunday, March 24, 2019

Align Risk and ROI analysis with success

Risk and return on investment (ROI) are usually evaluated separately. Yet, they share striking similarities.

Both need an internal (strengths and weakness) as well as external (opportunities and threats) analysis. This is also known as SWOT Analysis. They both analyze the two directions in which any effort can go, risk measures possible monetary loss while ROI measures possible monetary value. But what is at the core of risk analysis and ROI analysis? Impact and Likelihood.

Businesses, organizations and individuals are required to be productive for which they need to be effective and efficient. To be effective they need to have an impact. What they do, must return as high as possible monetary value with as low as possible chances of monetary loss in the lifespan of the delivery. To be efficient they need to be predictable exhibiting the highest possible success likelihood. How they do it, must use the leanest, fastest and highest quality possible approach (the lowest possible entropy solution).

Understanding this simple fact is one thing but learning it is another.

Since businesses are ultimately led by managers, success comes 100% of the time down to the individual. Hiring full stack leaders is at the core of low risk and high ROI results.

As a professional, you the reader, will not have more value just because of your success likelihood based on your skills but also because of the impact your decisions will end up having. In other words, it is not enough to be efficient, you must also be effective. I see too many people focusing on efficiencies but few people out of them are actually focusing on effectiveness for whatever reason. This most likely is the result of a simple fact: common sense is rare.

If I could give a sentence of advise that would be "Align productively towards the definition of success". I have tried to explain what to do and how to achieve this objective above.

Saturday, March 16, 2019

Full Stack Leadership brings Competitive Advantage

All these keywords/key-phrases/hashtags apply to the organization as a whole. They apply to deliverables and quality. To deliver maximum return on investment cost must go down and/or value must go up. Focus on keeping the pace rather than in resource utilization and the result will be a constant delivery of value.

Whether your business depends on an e-commerce website or sending men to the space these concepts still apply. Process engineering is not a pure science discipline, it is also an art. While these hashtags are as old as human thinking what is novel here is the value proposition to embrace them company wide, to have them as the driver of the organization strategy. Unfortunately we are too much focused working in the business instead of on the business. The collective application of these ideas lead to Innovation which is always a result of Collaboration, Communication, Critical Thinking, and Creativity.

The main problem we consistently face is that the people doing it are not the ones thinking it. Leaders should be thinkers and doers, both. Organizations that train their leaders to be full stack will exhibit competitive advantage and such advantage is indeed sustainable depending on how innovative the leaders' interconnections are.

Want to copy and paste?
#LessIsMore #EightyTwenty #KeepItSimple #ParetoPrinciple #TheoryOfConstraints #LawOfDiminishingReturns #SimpleAsPossibleButNotSimpler #MeasureTheRightThing #PerfectIsTheEnemyOfGood #GetItDone #BeEffectiveAndEfficient #GoldenMean #ExcessIsRecklessness #MIddeIsCourage #DefficiencyIsCowardice #DoTheRightThing #ContinuousImprovement #EvolutionNotRevolution #CommonSenseIsRare #Innovation #Collaboration #Communication #CriticalThinking #Creativity #WorkOnTheBusiness #TheWholeIsGreaterThanSumOfItsParts #BestPracticeIsTheEnemyOfCommonSense #BusinessStrategy #BusinessAlignment #BeThinkerAndDoer #DreamLeadershipNotManagement #DefineSuccess #BeFitForSuccess #FullStackLeadership
Have more? I am sure you do, that is what comments are for ;-)

Followers