Needs work
Project:
Internationalization
Version:
7.x-1.x-dev
Component:
Fields
Priority:
Major
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
17 Jul 2011 at 10:07 UTC
Updated:
1 Aug 2018 at 14:31 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
fietserwinThis issue depends on completion of #1221276: locale_get_plural() only works for a single language within a request and does not work for English.
Comment #2
loominade commentedthe issue #1221276: locale_get_plural() only works for a single language within a request and does not work for English has been fixed but affixes are still not working
Comment #3
loominade commentedsorry
Comment #4
liquidcms commentedany one know status of this? it does look like #1221276: locale_get_plural() only works for a single language within a request and does not work for English has been fixed but i still see no method of translating field suffixes/prefixes.
Comment #5
spleshkaAny progress here?
Comment #6
spleshkaAs i18n_field not translates all components of field suppose it is a bug that should be fixed ASAP.
Comment #7
spleshkaI found how to translate field suffix/prefix on entity add/edit form. But I have no idea how to translate them during field_attach_view(), because hook_field_attach_view_alter() got value that already was formated using suffix/prefix.
I attached a patch that could help someone to continue working on this issue.
Comment #8
spleshkaChange issue status.
Comment #9
nwom commentedThanks for the patch. It works great for the node edit form.
I would also love to know how to get the translation working for "field_attach_view."
Comment #10
5n00py commentedI confirm that prefix and suffix was in the local module.
But in my commerce installation (field attached to product) suffix not translated.
Comment #11
bojanz commentedThe patch needs to be rerolled since #1904368: [7.x-1.8 regression] Field translation fails in numerous situations landed and it makes some of the changes in the patch unneeded.
Furthermore, I see that the referenced Drupal core patch hasn't landed yet, isn't that a blocker for this issue?
Comment #12
vasikehere is the patch rerolled.
so the prefix/suffix should be translatable, but the translations still not used for the field view.
@bojanz: which Drupal core patch did you mean?
Comment #13
bojanz commentedProbably because you're changing $element instead of $alter_element.
Comment #14
vasikeusing $element it's ok, as it works for the field form alter - we have tranlated prefix/suffix.
within $alter_element won't work.
Comment #15
spleshkaRe-rolled patch without extra whitespaces.
Comment #16
vasikechanged the last patch: use $alter_element ($alter_element['#' . $element_property] <=> $element['value']['#' . $element_property]).
patch attached.
Comment #17
vlad.dancer#16: i18n_field-i18n_field-should-translate-prefix-suffix-of-number-fields-1221208-16.patch queued for re-testing.
Comment #18
Azraph commentedThought this patch would be applied in the dev release but it was not, now the patch made i18_field create prefix/suffix translation strings. they work fine in the new content / edit content forms. but still the display widget displays the original prefix/suffix string not the translated one.
Comment #19
jose reyero commented> still the display widget displays the original prefix/suffix string not the translated one.
So it seems there's still some work to do here.
Comment #20
jose reyero commentedWe need to add some tests before we add any other field feature: #2061999: Add tests for field translations to avoid regressions (i18n_field.test)
(And this one needs tests too).
Comment #21
vasikehere is a new patch that overrides the number fields output with prefix/suffix using the translated values of these settings.
Comment #22
Azraph commentedI patched a fresh dev release install of i18n and test results are:
There still a problem with the display widget, everything's still fine on add/edit forms.
On the default english node view an error msg appears and no prefix/suffix displayed:
Notice: Undefined index: suffix in i18n_field_field_attach_view_alter() (line 377 of /home4/azraph/public_html/sallefny/sites/all/modules/i18n/i18n_field/i18n_field.module).
On the translated node everything's fine including the prefix/suffix translation display.
Comment #23
vasike@Azraph : indeed. Thank you Sir.
tip : when a patch fails (is not working), please change the issue status to "needs work".
here is a new patch that should solve these errors.
Comment #24
Azraph commentedWorks perfectly, thank you @vasike
Comment #25
jose reyero commentedNeeds tests, see #20
Comment #26
vasikenew patch with number fields Test.
Comment #27
jose reyero commentedThis may work though the patch is still lacking a few things for using the API properly:
1. Metadata for these properties, it should be in i18n_field.i18n.inc i18n_field_i18n_object_info()
(See menu link properties about how to do it for nested properties, i18n_menu_i18n_object_info())
** Btw, do these prefix and suffix values show up properly in the field translation tab? (it should be fixed by the right metadata).
2. After that you'll find all the translating code can (and should) be simplified because we won't need that many specific lines for these two properties, they will be just translated when invoking i18n_string_object_translate()
Comment #28
vasikei can't get how these "nested properties" are supposed to work.
i mean i can't see 2. happening.
however here is patch that uses i18n_field_i18n_object_info() for these properties.
Comment #30
gaëlg#28 did not worked for me (the suffix was not translated on the node edit page). #23 worked but I got "undefined value" errors (such as for $settings['scale']) in some cases (maybe because I was using EVA module).
Using this
instead of this:
in the "// Translate number fields prefix/suffix if exist." part of the patch made it work, though I did not take the time to really understand what I did...
Comment #31
espurnes#26 gives the option to translate the prefix/suffix text through the translation interface.
It works perfect. Thank you.
Comment #32
andypostComment #33
pr1 commentedbased on #26 added t function as follows on i18n_field.module and I'm able to see translations
Comment #34
mas0h commentedI used the path #26 and it works fine, but when translating nodes with empty value of integer cck field that has translated prefix, I receive the following error message:
Warning :number_format() expects parameter 1 to be double, string given in i18n_field_field_attach_view_alter() in sites/all/modules/i18n/i18n_field/i18n_field.module
I have never had that error before applying the patch.
Comment #35
espurnesI applied the patch #26.
When I create a view and I show a Decimal field with prefix/sufix, drupal gets me this error for each value on this field.
The notice appears in all languages but english.
i18n without #26 patch does not show these notices.
I decided to use the dev version on i18n without prefix/sufix translation functionality. It's not what I need but it's better than has the notice.
If anyone can reproduce this issue and knows how to solve it, please, post it here. Thanks.
Comment #37
vasikethere is a new patch that includes the code suggested at #30.
@GaëlG : thank you Sir
i hope this will solve the "undefined value" errors (such as for $settings['scale']) issues.
and i hope will pass the tests.
do not try the patch from #26 anymore, check the #27 and #28 comments.
Comment #39
vasikeany help with the tests implementation for this field translation (testNumberFieldTranslation)
Comment #40
thulenb commentedI am a non-coder and don't know how to apply a patch properly. Nevertheless, I might be able after some Google research. The last Status of the patch is "failed testing". Does that mean that I shouldn't use the patch?
In general I was kind of surprised that it is currently not possible to translate Suffix and prefix. You can translate so much using entitiy translation and i18n but these little peaces are not translateable. One should think that almost every multilingual website faces this bug.
Comment #41
zekvyrin commentedIn patch #37, there is an issue with this part:
When using it, I received this error:
Thing is that the $setting variable is used to store $instance_current['settings'][-something-] 's value foreach loop, which in some cases can be "FALSE" for example (This is when this when I get the warning)...
Was it meant to be like this?
(marking as need review to trigger testbot)
Comment #43
Johnny vd Laar commentedThis patch is #42 + the fix in #30 for views. #37 mentions that it added #30 but I don't see the code in the patch.
Comment #44
Anonymous (not verified) commentedPatch #44 almost did it for me..
I've added a small fix for a different php version.
Replaced
if (isset($context['display']['settings'])) {by
if (is_array($context['display']) && isset($context['display']['settings'])) {Comment #45
s427 commentedFWIW, I tried applying the latest patch in this thread on a very simple use case where I need to translate the suffix of an integer field, and it works fine as far as I can tell.
Comment #46
Johnny vd Laar commentedI've modified the patch because I created my own custom field formatter and this one already does the i18n translation + adds extra spans etc. The patch should only replace the markup if it's one of the formatters provided by drupal core.
Comment #47
rudiedirkx commentedThe formatter shouldn't replace anything ever. i18n should create a new formatter, like it does with all other formatters, e.g.
list_text: Default translated.Comment #48
rudiedirkx commentedThis patch creates 2 new formatters:
i18n_number_integerandi18n_number_decimal. Default will still work, exactly as it used to. And Unformatted is still unformatted, which was broken with previous method. This is less intrusive and more inline with i18n. It's more code though, and won't work automagically.It uses all of number.module's formatter logic, so updates etc won't interfere.
Interdiff attached too:
Comment #50
rudiedirkx commentedAnd it also work for
number_floatfields, which previous patch didn't..?I don't know why tests fail, screw that, it works perfectly.
Comment #51
dan_metille commentedPatch #48 worked for me. In my case it is just a simple integrer with suffix for prices.
Don't know too why it failed testing. In any case, thanks for the patch!
Comment #52
minoroffense commentedI would actually argue that prefix and suffix should alway be shown in the translation form.
For example, english and french currency data in Canada use the following format:
English
$1.50
French
1,50 $
So the translation is the fact that the prefix is now a suffix.
Comment #53
rudiedirkx commentedI agree with @minorOffense
Triggering test?
Comment #54
rudiedirkx commentedOk, not triggering test...
Comment #56
rudiedirkx commentedRe-upload #48
Comment #58
rudiedirkx commentedWell, that's quite strange..... PHP 5.3 has 3 fails. PHP 5.6 has 2 fails =)
Comment #59
attiks commentedTested the patch, works like a charm, NR for testbot
Comment #60
markdc#56 working for me. If you're using Views, remember to choose the Default Translated formatter.
Comment #61
anybodyPatch #56 works great. I'm running it in production since several days. What has to be done before RTBC now?
Are the tests wrong or is the patch wrong?
RTBme ;)
Comment #64
joseph.olstadTwo remaining items left on this patch todo.
Here are the testbot results, two errors to fix:
Looks like the same cause.
Comment #65
Helrunar commentedPatch #56 works like charmed for me :-)
Comment #66
lxndr commentedDoes #56 work with i18n 7.x-1.17?
Comment #67
lamp5Yes, it does work
Comment #68
skoff4eg commentedHello everyone, tell me please, where can I translate the prefix and suffix? Unfortunately I did not find any settings. Drupal 7.54 and i18n 1.17. Thank you!
Comment #69
duneblPatch #56 apply with few warnings
Comment #70
spadxiii commentedA new patch with just a quick re-roll against the latest dev.
Comment #71
sano commentedpatch #70 works fine with the 7.x-1.24 (as well as with the older 7.x-1.22). Thank you.
Comment #72
vdsh commentedTo answer #68: you need to select the formatter as Default (translated), then display the page containing this field in another language, and then translate it the usual way (eg with admin/config/regional/translate/translate)
However, #70 doesn't work for me with plurals on the node edit form - maybe I am missing something:
My suffix is ' meter| meters' which is translated (in french) to ' mètre| mètres'
In the i18n_field_field_widget_form_alter, in the // Translate field properties function, I have:
$property_value = ' meter| meters'
$translated_property_value= ' mètre| mètres'
but my $element['value']['#' . $element_property] = ' meters'. It has already been set to the plural form therefore it never validates the $element['value']['#' . $element_property] == $property_value and doesn't get translated.
I don't know how this should be handled, I changed it to
which works for me - but don't know if it's the ideal solution