taxonomies translation

86 views
Skip to first unread message

Vedran Serbu

unread,
May 6, 2020, 6:09:39 AM5/6/20
to AtoM Users
In ATOM 2.5 , in MANAGE -> TAXONOMIES -> Actor entity types, there is no option to edit current entity type (corporate body, family, person) and in that way to translate the terms. Only option is to ADD NEW. 

Is there any other way to translate it (I need it for croatian, and it is not translated through weblate)

best regards,

Vedran

Dan Gillean

unread,
May 6, 2020, 3:01:13 PM5/6/20
to ICA-AtoM Users
Hi Vedran, 

There are a couple of ways that we can do this. First, and explanation: 

The Actor Entity Type terms come from the ISAAR-CPF Standard, and there are some places in the AtoM code that use the default terms. For this reason, we lock the terms - mostly to ensure that they are not deleted, which could break some of AtoM's authority record functionality. This is explained a bit more in the documentation, here: 
In any case, adding a new translation to a locked term will not break AtoM, so we can proceed. 

These terms are also what are known as fixtures - that is, they are default terms that we load into the database when AtoM is first installed. You are correct that our volunteer translator community adds fixture translations, which will show up in new installations when they are included in the next release. 

However, we ALSO have a known issue for upgrading users. Essentially, we don't currently have a process of migrating and adding new fixture translations - so when a user upgrades and they load their database into the newly installed site, your old database overwrites any new translations that might have come from our translation platform! For long-term AtoM users, this makes it hard to get new translations for taxonomies and locked terms. This problem is described in the following issue ticket: 
In the meantime, we have some workarounds available, so you can manually add the translations you need yourself. 

The first method is to use a script that one of our developers prepared. I have previously shared the script, and basic instructions on its use, here: 
As always, we provide this script freely, but take no responsibilities for any unexpected issues it may cause - so please, backup your database before you proceed

The second option is to accomplish this via SQL. I have been working on a new documentation page for 2.6 that includes a number of AtoM SQL queries - it is not yet available on the AtoM website, but you can see it on GitHub here: 
Keep in mind that we use Sphinx for our AtoM documentation, and GitHub uses Markdown, so while most things render properly on GitHub, some aspects like links will not display properly. 

In this new documentation, I did include some queries for working with terms and taxonomies, here. I had included a query to allow a user to provide a translation for a taxonomy name, but didn't include one for translating a term (I forgot about locked terms). However, it's easy to modify the Taxonomy query and use it for a term as well. I will explain the process below. 

Once again: please proceed at your own risk, and make sure you backup your database before you proceed! 

Step 1: access the MySQL command prompt

To access the MySQL command prompt so we can run SQL queries,  we will need to know the MySQL username, password, and database name used during installation. If you can't recall for certain what credentials you used, you can always check in config/config.php - for example, to see this file you could run the following from the root AtoM installation directory, which should be /usr/share/nginx/atom if you have followed our recommended installation instructions: 

  • sudo nano config/config.php

You should see the database name and credentials listed near the top of the file. You can also check your database username and password in /root/.my.cnf like so:

  • sudo cat  /root/.my.cnf

Once you have the database name, MySQL user name, and password, we can use these to access the MySQL command prompt. Assuming in the following example that your database name is atom and your user and password are root, you could access the prompt like so: 

  • mysql -u root -proot atom;

Notice that there is a space between the -u and root, but NOT between the -p and the root password. Alternatively, you can leave no password following the -p, and you will be prompted to enter it by the command prompt before proceeding. 


At this point, we should have access to the MySQL command prompt, which should look like this: 


mysql>


Step 2: Find out the Actor entity types taxonomy ID

Next we need to find out the ID of our taxonomy. We can use the following query to see taxonomy names and ID values: 
  • SELECT id, name FROM taxonomy_i18n WHERE culture='en';
This will return something like the following: 

+----+-------------------------------+
| id | name                          |
+----+-------------------------------+
| 30 | NULL                          |
| 31 | Description Detail Levels     |
| 32 | Actor Entity Types            |
| 33 | Description Statuses          |
| 34 | Levels of description         |
| 35 | Subjects                      |
| 36 | Actor Name Types              |
| 37 | Note types                    |
| 38 | Repository Types              |
| 40 | Event Types                   |
| 41 | Qubit Setting Labels          |
| 42 | Places                        |
| 43 | ISDF Function Types           |
| 44 | Historical Events             |
| 45 | Collection Types              |
| 46 | Media Types                   |
| 47 | Digital Object Usages         |

... etc

As we can see, in my installation, the Actor Entity Types taxonomy has an ID of 32. We can now use this ID for Step 3 - finding out the ID of the term we want to update. 

Step 3: Find the ID of the term you want to update

Now that we have the ID of our taxonomy, we can use this to get the IDs of the terms in the taxonomy: 
Note the ID of 32 is used for the term.taxonomy_id parameter, which we got from Step 2. This query should return something like the following: 

+-----+----------------+
| id  | name           |
+-----+----------------+
| 131 | Corporate body |
| 132 | Person         |
| 133 | Family         |
+-----+----------------+


For step 4, I am going to add a translation for the term Person - so I will use ID 132. 

Step 4: Insert a new translation

Now we have all the pieces we need! We just need to know the two-letter ISO 639-1 culture code for our chosen language. In my example, I am going to add a Catalan translation (culture code: ca) to the term Person. 

First, terms are primarily stored in 2 tables - term, and term_i18n. Basically any field in AtoM that can be translated will be stored in a table with the suffix of _i18n (a shortening of internationalization).We will want to insert our new translation into the term_i18n table.  We can see the fields available in that table like so: 
  • describe term_i18n;
+---------+---------------+------+-----+---------+-------+
| Field   | Type          | Null | Key | Default | Extra |
+---------+---------------+------+-----+---------+-------+
| name    | varchar(1024) | YES  |     | NULL    |       |
| id      | int(11)       | NO   | PRI | NULL    |       |
| culture | varchar(16)   | NO   | PRI | NULL    |       |
+---------+---------------+------+-----+---------+-------+


Now, knowing the ID of my term and the language code of my chosen translation culture, I can insert a translation row. Remember in my example below, I will insert a Catalan translation for "Person"  (i.e. "Persona"): 
  • INSERT INTO term_i18n (name, id, culture) VALUES ('Persona', '132', 'ca');
Change the translation, term ID, and culture values as you need. 

If it works, then great! You are almost done! Repeat as needed for other terms. After that, you can exit the MySQL command-prompt by entering exit - you will be returned to the unix/linux command-line interface. 

Step 5: run a few maintenance tasks

Before we check if our translation worked, we need to do a few more quick things. First, make sure your chosen culture is added to AtoM in Admin > Settings > i18n languages. See: 
Now, in the command-line interface, we will want to restart PHP-FPM (and Memcached if you have it installed), clear the application cache, and re-populate the search index. Make sure you run the following commands from AtoM's root installation directory - typically this is /usr/share/nginx/atom if you have followed our recommended installation instructions. 

Restart PHP-FPM
  • If you are using PHP 7.0: sudo systemctl restart php7.0-fpm
  • If you are using PHP 7.2: sudo systemctl restart php7.2-fpm

Restart Memcached
  • sudo systemctl restart memcached

Clear the application cache
  • php symfony cc
See: 
Repopulate the search index
  • php symfony search:populate
See: 
Finally, remember that your web browser has a cache as well - if you are not seeing the changes, you might want to clear this too, or test in an incognito browser window. 

Let us know if that works!

Cheers, 

Dan Gillean, MAS, MLIS
AtoM Program Manager
Artefactual Systems, Inc.
604-527-2056
@accesstomemory
he / him


--
You received this message because you are subscribed to the Google Groups "AtoM Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ica-atom-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ica-atom-users/41acb97f-18eb-4bd5-a699-f29949937f21%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages