Categor铆as
c贸digo abierto Mundo 2.0 programaci贸n Tutoriales WordPress

Trabajando con SVN (y WordPress)

Esto es un reblog de trabajo para no perder el archivo. C贸mo usar SVN para tus traducciones de WordPress, en ingl茅s. Lo guardo por hist贸rico, porque en pr贸ximas versiones esta forma de trabajar dejar谩 de funcionar.


Using SVN in your translation flow聽is not as hard as it seems. If you know some of the basics, you can聽update a repository (for themes, plugins, or core) in an easy way. Let’s begin :).

We are going to work with the example of the Spanish (Spain) translation. What do we need to begin with?

Permissions

First of all, we need to have permissions granted to write to our Subversion repository. We can ask for聽this access in the make/polyglots site.

make-polyglots

Don’t forget to:

  • Ask for access politely
  • Indicate聽your wp.org user
  • Indicate聽the repository you want access to (you need to be a validator for your language to be granted commit access)
  • Tag your post with聽request. Locale tags are not needed, as they are automatically associated with validators, but they will be appreciated by others translators and validators.

Creating聽your own local copy

Now that you have access to the repository, you need to make聽your own local copy to work with it.

First, you need to locate your locale’s repository.聽You can look for it in聽https://i18n.svn.wordpress.org. Once you have located it, copy the URL. For the Spanish example, the URL is https://i18n.svn.wordpress.org/es_ES/

The next step is to make the copy. If you are a Mac or Linux user, you only need to go to a terminal. If you are a Windows, user, you can install Win32SVN to work with a terminal with SVN.

We are going to use SVN. SVN is an abbreviation for Subversion, a software versioning聽and revision聽control by Apache. SVN (and other revision control software, like git) allow the programmers to work in a collaborative way and allow to all the people involved to look at and review the code, modify it, and revert it if there is any problem.

Once you have your terminal ready, you need to write this with your own locale:

svn-co

Now you’ll see a lot of archives being copied, and you will have聽all your locale repository copied in your local directory.

archive

copied

SVN basics

Note that you are right now in a SVN repository. You can see what others have done in the repository by using the command svn log. When you submit your聽changes, others will see your activity in the logs.

SVN is a little wayward. When you are in a SVN repository, you need to remember to alway use the command svn to do things.

  • if you want to copy something, you need to use聽svn copy or聽svn cp
  • if you want to move something, you need to use聽svn move or聽svn mv
  • if you want to delete something, you need to use聽svn delete or聽svn del
  • if you add a new file to a directory and want it to be in the SVN repository, you need to use聽svn add <file> to add it to the next commit

You have a list of all the available commands writing svn help in your local repository.

blame

Creating a new tag and/or branch

Now that we have our local repository, we need to create our new branches and tags. We are going to work with the example of WP 4.0-alpha.

As we see before, when you create a new file or archive you need to add it to the repository. If you do not add it, you will not be able to commit your files to the repository.

To make things easier, we are going to svn copy a prior directory and modify the files.

First step, we go into the聽tagsdirectory. We will have a list of all prior tags.

Now, we copy the last directory created to a new one with our version:

svn-cp

Done! Now we can navigate with our browser to make things easier.

Understanding the repository

In our new directory we will see two directories:聽dist and聽messages.

The dist directory has this content:

  • license.txt – the license archive
  • licencia.txt – name may vary. This is the license in your language.
  • readme.html – the readme file in your language.
  • wp-admin/setup-config.php – a translated version of the setup in your language
  • wp-config-sample.php – a translated version of the config sample in your language

The messages directory has this content:

  • admin-xx_XX.mo – the translation archive for the administration ( link聽)
  • admin-xx_XX.po – .po version
  • admin-network-xx_XX.mo – the translation archive for the network administration ( link聽)
  • admin-network-xx_XX.po – .po version
  • continent-cities-xx_XX.mo – all the translated Continents and Cities to your language ( link )
  • continent-cities-xx_XX.po聽– .po version
  • xx_XX.mo – the main WordPress translation ( link )
  • xx_XX.po聽– .po version
  • twentyxxxxx – the translation of each official theme (various directories)
    • xx_XX.po
    • xx_XX.po

Updating your files

At this point, we need to update the files of our new directory to commit the new version. To do this, we need to know how are we going to build the new package.

packagesIf you聽are going to use the聽translate.wordpress.orgoption,

  • All the installation and setup archives will be read from our new /dist directory (and we will tell the system聽where they are)
  • The translations will be read from the translate.wordpress.org site

If you聽choose the Subversion option,

  • All the installation and setup archives will be read from our new /dist directory (and we will tell the system聽where they are)
  • All the translations will be read from our translations svn directory (and we will tell the system聽where they are)

You should聽always try to use the first version. If you need to use the second version, then you will need to:

  • go to each one of the translation sites in translate.wordpress.org (you have the links here)
  • export the translations in .po and .mo versions
  • change the names of the archives to match the list before
  • put them in聽the svn directory in their correct place

Regardless聽the option we want to use, we need to update the archives in the聽dist聽directory. Usually, you will only need to update the version number in the readme.html file. If you need to do something else, it will be mentioned聽in the聽make/polyglots聽site.

readme

After finishing with the archives and changes, we can use the command svn status聽in our parent directory to see the changes that are going to be committed.

svn-status

Committing changes

  • If we are committing a minor version (3.9.1 for example), we will need to commit a tag with the new version
  • If we are committing a聽major version (4.0 for example), we will copy this new tag to a branch to upload the tag and branch

svn-branch

If we are using the Subversion option we will see the list of all .po and .mo archives; it’s a good idea to update the .mo and .po archives in the /trunk directory as well.

If we are using the translate.wordpress.org option, we are ready to commit our changes.

The command to commit our changes is svn commit or svn ci. We will add a message using the -m subcommand, containing:

  • the version we are uploading
  • the language we are uploading
  • please use english to make understanding easier

svn-commitAnd done! We are ready to go to our local WordPress.org site and build the new version of WordPress.

Building a localized WordPress 聽version

If you have just committed the files to the repository, you will need to wait a bit to see it appear in your local WordPress.org site.

Once it’s working, you need to select:

  • the translate.wordpress.org聽option
  • the /dist/ directory
  • the development (trunk) project

The WordPress version will change and you will see the last version in development. The revision number will be ignored, it only works in the Subversion option.

version-2

If you want to build an official release version, you will need to look in the project list and select the one that you are looking. You will get the last minor version released. Again, the version will be automatic and the revision number will be ignored.

version-prior

You can build and distribute as many beta and release candidate versions as you want. They will automatically go to the beta and release candidates place.

rc-versions

Categor铆as
c贸digo abierto Mundo 2.0

Usando git en (pre)producci贸n

Desarrollando con git

Desarrollar es un trabajo pesado, eso lo sabemos todos. Sobre todo, si queremos cumplir con todas las聽buenas pr谩cticas que deber铆amos.

Una de esas buenas pr谩cticas es聽llevar un control de versiones de tu software. No porque necesites separar la versi贸n 1 de la 2, sino porque llevar un control de versiones exhaustivo te ayudar谩 despu茅s a encontrar errores, a poder revertir cambios, y a que otros (o t煤 mismo dentro de dos meses) puedan revisar tu c贸digo para ayudarte a mejorar.

Muchos de nosotros, cuando estamos desarrollando algo, lo hacemos en un estado que llamamos de聽preproducci贸n. Esto s贸lo quiere decir que nuestro desarrollo no est谩 abierto a todos, visible. Por tanto, es un sitio de pruebas, donde nos da igual que se escupan errores por pantalla, o que la p谩gina est茅 descuadrada.

Cuando estamos haciendo ese trabajo podemos hacer 100-200 cambios al d铆a, y llevar un control de versiones de cada uno de los cambios que hacemos se puede convertir en algo pesado. 驴C贸mo lo convertimos en algo asequible? Automatiz谩ndolo.

El scripting

Soy de los que usan git聽(y SVN) desde聽consola. Para m铆 es mucho m谩s r谩pido porque juego con el聽scripting.

Por un lado, tengo una serie de alias definidos:

  • alias fp=’git format-patch’
  • alias ga=’git add .’
  • alias gc=’git commit -a -m’
  • alias gp=’git push origin master’
  • alias log=’git log –pretty=oneline’
  • alias sinc=’sh /Users/raven/Git/sinc’
  • alias st=’git status’

De esta forma, cada vez que tengo un cambio nuevo, los comandos a ejecutar son los siguientes:

> ga
> gc "mensaje de descripci贸n del commit"
> gp

Mi estructura de directorios incluye, en mi carpeta de usuario, una carpeta /Git donde tengo todos los repositorios de trabajo. Para cada uno de ellos tengo un peque帽o script que lanza una sincronizaci贸n con el servidor, de forma que si he cambiado algo all铆,聽ese cambio se reflejar谩 en mi directorio local.

As铆, s贸lo tendr茅 que ejecutar聽un comando, y se actualizar谩 mi copia local. Todos los scripts de actualizaci贸n los tengo en la carpeta /Git, en vez de dentro de cada uno de los repositorios, para que no interfieran con las copias.

git/raven.es> sh ../raven.sh

Ese archivo raven.sh tiene el siguiente contenido, que cambia para cada uno de los repositorios:

expect -c 'spawn rsync -avrhz -e "ssh -p" --progress --delete --exclude-from "/Users/raven/Git/exclude.txt" MIUSER@MISERVER:MIDIRECTORIO/raven.es/ /Users/raven/Git/raven.es/ ; expect password ; send "MIPASSWORD;\n" ; interact'

Este archivo exclude.txt tiene, en cada l铆nea, nombres de archivos o directorios que se ignorar谩n en la sincronizaci贸n, y puede tener el contenido que necesit茅is. En mi caso, el archivo tiene el siguiente contenido:

sources
public_html/database.*
core.*
.svn
.git
stats
backup_site
backup
*/backup
versiones-backup
uploads
blogs.dir
upgrade
logs
cgi-bin
*.tar.gz
hiccup
wp-content/uploads/
wp-content/blogs.dir/
wp-content/upgrade/
error_log
*/error_log
cache
*/cache

Automatizando a煤n m谩s

En mi directorio Git tambi茅n tengo un archivo, sinc, que lanza la sincronizaci贸n de todos los repositorios, lanzando uno a uno los sincronizadores individuales.
Aqu铆 las posibilidades son m煤ltiples. Dependiendo de vuestra forma de trabajar, os puede interesar lanzar la sincronizaci贸n y el git add en la misma orden, o hacerlo todo en bloque. Pod茅is fabricaros vuestro propio script a medida.

Lo que ten茅is que recordar es una cosa importante. Si hay algo que hac茅is muchas veces de forma parecida, invertid tiempo en automatizarla. En muy poco tiempo notar茅is la diferencia.