Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
The function i18n_taxonomy_term_get_translations() in it's current state only returns the term of which the term id is given as an argument. Instead of loading one term, the function should return all terms belonging to the translation set of the i18n_tsid given as an argument.
Comment | File | Size | Author |
---|---|---|---|
#18 | i18n_taxonomy-1155214-18.patch | 2.46 KB | skilip |
#15 | i18n_taxonomy-1155214-15.patch | 1.07 KB | skilip |
#8 | i18n_taxonomy-1155214-8.patch | 1.88 KB | skilip |
#6 | i18n_taxonomy-1155214-6.patch | 2.27 KB | skilip |
#4 | i18n_taxonomy-1155214-4.patch | 1.89 KB | skilip |
Comments
Comment #1
skilip CreditAttribution: skilip commentedComment #2
skilip CreditAttribution: skilip commentedComment #3
BerdirThat check is IMHO unecessary. It's a required argument and you pass in an invalid argument, bad things will happen. That's true for most drupal API functions. Also, is_numeric() actually allows things like "-123e12" so you can still pass in invalid stuff if you really want to.
Only use db_select if you have to (dynamic queries, node access, ...) because it is slower than db_query().
Can be written as:
Powered by Dreditor.
Comment #4
skilip CreditAttribution: skilip commentedThanks for the review!
Comment #5
BerdirThis means that you re-create the complete array every time so the static cache is pretty much useless. You need "$translations[$i18n_tsid] = ... ".
Powered by Dreditor.
Comment #6
skilip CreditAttribution: skilip commentedYou're right
Comment #7
skilip CreditAttribution: skilip commentedComment #8
skilip CreditAttribution: skilip commentedForgot to remove dpm()
Comment #9
BerdirYes, this looks good now.
Just wondering, is this function never actually used anywhere in the i18n project?
Comment #10
skilip CreditAttribution: skilip commentedFormerly it was used in i18n_taxonomy_translate_terms, which is indeed not used anymore. However we're working on a patch which adds a 'translation' tab to term edit pages in which this function is needed: #1155238: Create translation tabs for terms
Comment #11
BerdirOk great, then let's get this in :)
Comment #12
Jose Reyero CreditAttribution: Jose Reyero commentedWe may later use translation set functions (i18n_translation) for this, but anyway, better to have a working api function than a broken one.
Committed, thanks.
Comment #13
Jose Reyero CreditAttribution: Jose Reyero commentedKeeping our list clean.
Comment #14
skilip CreditAttribution: skilip commentedJust discovered that the function i18n_taxonomy_term_get_translations() can be replaced by i18n_translation_set_load(). Will create a patch for it later on. Sorry for inconvenience.
Comment #15
skilip CreditAttribution: skilip commentedComment #16
Jose Reyero CreditAttribution: Jose Reyero commentedYes, sorry I had missed that too.
Anyway, for this function, I think we should re-purpose it to work just as translation_node_get_translations() taking a tid argument, or a full term object, which I think could be handy for other functions here, as you could iterate over the resulting array, etc.. http://api.drupal.org/api/drupal/modules--translation--translation.modul...
Btw, there's also i18n_taxonomy_translation_set_load(), which is the one to be used here, it is mostly a specific wrapper for taxonomy.
Comment #17
skilip CreditAttribution: skilip commentedCan't we just delete i18n_taxonomy_term_get_translations? The function isn't used anywhere anymore
Comment #18
skilip CreditAttribution: skilip commentedThis patch removes usage of the function i18n_taxonomy_term_get_translations() and replaces it with i18n_translation_set_load().
Comment #19
webflo CreditAttribution: webflo commentedGood cleanup. Thx committed in 4e9f16c
Comment #20
webflo CreditAttribution: webflo commented