Hi there,
We can use SQL to output a list of the various taxonomy names in a selected culture. For good measure, I strongly recommend that you make a backup of your database first before you start changing things, just in case!
Make sure your language is added in the language settings, and you site has been reindexed
If you haven't already done so, then before we proceed make sure that you have navigated to Admin > Settings > i18n languages, added Catalan (or whatever secondary culture you are using), and pressed save. See:
However, this alone is not enough - we need to make sure that your site has also been reindexed once you add a new language. This is done from the command-line - from AtoM's root installation directory (typically /usr/share/nginx/atom), run:
- php symfony search:populate
Now we should be ready to begin! Let's start by accessing MySQL.
Accessing the MySQL command prompt
To use the query I will provide below, we will first need to access the MySQL command prompt. To do that, 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:
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>
Now we can enter our query!
Show taxonomy names in English and another culture
You can now use the following SQL query to output the taxonomy names in English and Catalan:
- SELECT id, culture, name FROM taxonomy_i18n WHERE culture='ca' OR culture='en';
If there no rows in the resulting output with a culture of "ca", then there are currently not any Catalan translations for the taxonomy in question in your database.
Add a Catalan translation to an existing Taxonomy
We can also use SQL to add a Catalan taxonomy name if one doesn't exist. I will use the Places taxonomy as an example below. First, we need to know the ID of the Places taxonomy, which the results of the previous query can show us - in my output, Places has an ID of 42. I can now add a Catalan name for this taxonomy like so:
- INSERT INTO taxonomy_i18n (name, id, culture) VALUEs ('Llocs', '42', 'ca');
If there was already a Catalan taxonomy name translation that was output in the last query, but you wanted to change it, then you could use UPDATE instead:
- UPDATE taxonomy_i18n SET name='Llocs' WHERE culture='ca' AND id=42;
Now we should be ready to exit MySQL (just type exit into the MySQL command prompt) and try our taxonomy normalization again!
Tips for running the taxonomy normalization task
First: you might want to check the default installation culture of your site. You might be entering Catalan data into your site while it is configured to use English as the default culture, for example! In that case, you would actually need to normalize in "en".
You can check the default culture of your site in apps/qubit/config/settings.yml
If you change the value of the default installation culture, you will need to:
- Restart PHP-FPM
- In Ubuntu 14.04 with PHP5: sudo service php5-fpm restart
- In Ubuntu 16.04 or 18.04 with PHP7.0: sudo systemctl restart php7.0-fpm
- In Ubuntu 16.04 or 18.04 with PHP7.2: sudo systemctl restart php7.2-fpm
- Restart memcached if you are using it
- In Ubuntu 14.04: sudo service memcached restart
- In Ubuntu 16.04 or 18.04: sudo systemctl restart memcached
- Clear the application cache
- Re-index your site
- php symfony search:populate
Next: I have fixed this in the upcoming 2.6 documentation branch, but realized that it's not yet fixed in the 2.5 docs example - but, if you are running the taxonomy:normalize task in another culture, then you should provide the taxonomy name in the target culture - so, for our Places taxonomy in Catalan, try the following:
- php symfony taxonomy:normalize --culture="ca" "Llocs"
Another thing I remember from earlier versions, that seems to be fixed in 2.5 and later: if you have having issues normalizing in another culture when the taxonomy name includes an accent, try it without the accent:
- php symfony taxonomy:normalize --culture="ca" "Matieres"
Hopefully these tips will help - let us know how it goes!