As a translator, you are not able to translate strings at Create content -> Page, Story and their description.
As from translations@drupal.org (by Gabor Hojtsy):
These strings are inserted into the database at install time. Unless you
have these translations imported before the system.install script runs
(which is not possible, even if you use the autolocale module and
localized profile which imports at the earliest possible). The
system.module is forced to be the first to be installed so it is not
possible yet to release an install profile, which does anything before the
system module install script is run. So we cannot help these English
strings there.
Comment | File | Size | Author |
---|---|---|---|
#27 | Drupal.fix.node.type.name.t.patch | 2.18 KB | Gábor Hojtsy |
#15 | node_type_translate_0.patch | 1.47 KB | profix898 |
#13 | node_type_translate.patch | 1.02 KB | profix898 |
#12 | bug_1.jpg | 61.07 KB | meba |
#7 | cs.tar | 500 KB | meba |
Comments
Comment #1
webchickIs this still valid? A couple days ago, a patch went in to create these at install time, with t()s in place.
Comment #2
moshe weitzman CreditAttribution: moshe weitzman commentedComment #3
meba CreditAttribution: meba commentedTested yesterday with 5.x-dev. Still valid and i think that even more critical.
Comment #4
meba CreditAttribution: meba commentedTested now with CVS. Bug still appears.
Comment #5
webchickmeba, can you give us steps to reproduce this bug?
Comment #6
meba CreditAttribution: meba commentedSure. Install fresh Drupal CVS site, enable Locale, go to Localization. Add language: Czech (Čestina).
Then import cs.po (see attachment to this bug) to this language. Enable Czech and make it default. Please notice 100% is translated.
Now click "Vytvořit obsah" and you will see english Page & Story links.
Comment #7
meba CreditAttribution: meba commentedAttachment again
Comment #8
webchickI was unsure about translation issues myself, so I asked meba in IRC for some more info.
Basically, if you look at this .po file, you'll see the following:
The problem is, because those strings are defined, it should be using them when you click "Create content" but it isn't.
Comment #9
Steven CreditAttribution: Steven commentedI'm not sure we can fix this... the user can define any content type, we can't provide translations for all of them. An admin in another language should just translate his content type names directly in the UI, not use .po files for it. But, perhaps we can add a hack to the install.php locale where it can provide localized version of default variables and set ups.
If you actually want multiple languages for your content type names, then you have to use i18n. I imagine this is yet another feature to be added to its responsibilities as CCK comes into core.
Comment #10
webchickWould wrapping these in st() rather than t() make sense? Then whatever the installer version of the language would catch it?
Or am I talking out of my ass again? ;)
Comment #11
RobRoy CreditAttribution: RobRoy commented@webchick - That sounds like my ass talk you've stolen!
Marking normal priority since you can just use the UI to rename the posts.
Comment #12
meba CreditAttribution: meba commentedDid anybody of you just tried? Except webchick of course. You can't. There is no way how to translate these two strings.
Actually, this is very interesting. Try "Create content" and then you will see page with "Page" and "Story" untranslated. But menu items under Create content are translated correctly.
And for Steven: This has nothing with i18n. Drupal 5.0 just fails to translate >default content types Page & Story.
Maybe a screenshot will help? See attachment.
Comment #13
profix898 CreditAttribution: profix898 commentedMaybe I am missing something, but the strings are simple not wrapped in t() at all. The patch solves the issue for me (tested with German localization).
Comment #14
meba CreditAttribution: meba commentedGood catch! But you have to add t() to $type->description too.
Comment #15
profix898 CreditAttribution: profix898 commentedRight, description also needs to be translated and the title on node/add/xxx pages too. Patch updated.
Comment #16
meba CreditAttribution: meba commentedRight. Good now. BUT.
New configurable node body and title strings do not pass these strings to t() too.
See line 2936 in node.module
This may be right, because this string is user configurable. But Page & Story are default types, which should be translated at all costs. Otherwise, despite of importing lang.po, user will need to go to Admin - Content Types and edit title & body.
Therefore i propose:
What do you think?
Comment #17
Gábor Hojtsy1. We have a rule in Drupal to use t() for literal strings. Please do not wrap variable strings in t() unless you are absolutely sure that it comes from a literal string elsewhere. Please do not accept patches to t() node type names and descriptions in runtime, if we are still obeying this rule (and we do as far as I know). This rules out profix898's patches.
2. Story and Page are default node types added into the database before translations can be imported (unless you use the autolocale module and locelized profile I am working on). So t()-ing them in default_profile_final() does not help (there is no language setup and no strings imported at that time). st()-ing them helps *if* you use the installer with a language PO file, since then the type names will be added into the database with their localized name.
Nothing will help that the Drupal locale module (up to at least Drupal 5) is not intended to translate non-literal strings, and it is not advised to be used as such. So if you don't use the installer with a locale file in place (ie. with a translated interface), the current Drupal architecture can't help in translating the node type names. If you import the language strings after Drupal is installed, these type names will stay English, since these are already in the database, and the locale module is not to be used with non-literal stuff.
By the way moving the t()-ed strings in default_profile_final() to be st()-ed would also make them disappear from the runtime string collection, so it will not be expected to be translated anyway.
Comment #18
Steven CreditAttribution: Steven commentedAm I missing someting here? Fresh checkout of HEAD.
We do not localize the anonymous user name, input format names, taxonomy term names, forum vocabulary name, etc. All user-editable content must be localized by hand. This is how it has always been in Drupal. i18n allows you to get around this.
Yes, it is more visible now, but the problem has always existed and hasn't changed at all.
Comment #19
Gábor HojtsySteven, we are translating most customizable strings shipped by default before being inserted into the database. An example process: you import a locale, go to the user settings form and see the user mails editable in the used locale, because those are not yet saved, so shown translated. After you save them, they are keep being in the language you saved them in, and never translated by Drupal to another language.
This issue become a lot more visible because default node types shipped are not showing this behaviour.
Comment #20
meba CreditAttribution: meba commented1. We have a rule in Drupal to use t() for literal strings. Please do not wrap variable strings in t() unless you are absolutely sure that it comes from a literal string elsewhere. Please do not accept patches to t() node type names and descriptions in runtime, if we are still obeying this rule (and we do as far as I know). This rules out profix898's patches.
Then why menu items (see screenshot) are translated? This is not different case.
Comment #21
meba CreditAttribution: meba commentedWe do not localize the anonymous user name
This is NOT true. Anonymous user name is localized immediatelly after you import lang.po. This is the same case. Why anonymous user name (user editable string) is localized and default node type name is not?
Comment #22
chx CreditAttribution: chx commentedI agree with Steven: this is not locale's task. If you want to ship a Hungarian Drupal, create a drupal-hungarian.profile and update node_type with an SQL. This is user input data which kind is not translated at all.
Comment #23
RobRoy CreditAttribution: RobRoy commentedThe issue we need to look at here is this: Why when default_profile_final() is called, are those t()s not pulling the translated strings from the installer's .po file. Is it because we're using t() instead of st()? If so, that is a bug (or just quirky behavior) and we'd need to document/fix it. That would be weird though since even though we have access to a full bootstrap in profilename_profile_final(), we still must use st() as the translation is somehow not truly active yet.
@meba - Can you try switching those t() calls to st() in that function and see if that works for you?
Comment #24
RobRoy CreditAttribution: RobRoy commentedOops. I mean, we need to figure out why t() isn't pulling the translated strings from the database in default_profile_final() since in theory the installer's .po strings should have been put in the db at that point.
Comment #25
RobRoy CreditAttribution: RobRoy commentedSorry chx for the cross-post, but I think this is a valid issue. We already have the facility in place in st() to pull the language strings from the selected $install_locale so I think we should be able to translate any default setup right off the bat. I just don't have time to test this ATM, but will a bit later if no one else can.
Comment #26
Gábor HojtsyIndeed, this is a bug. Menu items should not be translated there.
Because you did not save the general settings page before you did import your translation. Try saving those settings into the database before importing the translation, and it will not get translated.
Note that it will only work if you have these strings in the single PO file used in install time (the $langname.po you put into the install profile folder).
Every data which becomes user input once saved into the database but is a literal string provided by default by Drupal is translateable or at least this is the theory. This includes editable menu item titles, user related emails, etc. This kind of user input is translated "before it becomes user input".
RobRoy, there is no default language added in the installer, and there are no strings imported by Drupal 5 (in the default profile). So the installer strings will definitely not end up in the database, they are read for one time usage into the memory, and then thrown away. There is no need to add the weight of the installer strings to a live site, as these strings are not used on a live site.
Comment #27
Gábor HojtsyThis patch tries to fix the st() issue and the node types accidentaly being translated in the menu. Needs testing/review.
Comment #28
Gábor HojtsyOK, grabbed a fresh checkot of HEAD, patched it with my patch, added a hu.po (Hungarian installer.po) with these lines added and done the install. Now I see Boo and BooHoo as the two names of the types on the installed interface, ready to get used.
It works for me. I don't think we can do anything better then this for Drupal 5.
Comment #29
chx CreditAttribution: chx commentedGoba, thanks for explanation and patch.
Comment #30
profix898 CreditAttribution: profix898 commentedI didnt have time to test the latest patch yet! But what is about the people upgrading from 4.7? In 4.7 these strings were hardcoded in story/page.module and therefore translatable. Will these strings also be converted when the module node types are replaced with cck-like content types? And will the content type names be translated depending on locale? Or will it be one name for all languages?
Comment #31
webchickIn 4.7 the translation will be for the term 'page' not 'Page' so I think that is a moot issue; they'll need to update their translations either way.
Comment #32
Gábor Hojtsy@profix898: system_update_1005() does the update you are talking about (in modules/system/system.install). That inserts the strings t()-ed, so if a translation of these strings are ready in the database at that point, then these will get translated.
As webchick pointed out, the node types were named page and story (note the all lowercase name), so it is unlikely that people are going to have Page and Story translated in their database. This means, updaters will get the English names for these node types (unless they first import a translation of Drupal 5, or at least the translation of these strings).
Comment #33
profix898 CreditAttribution: profix898 commented@Gábor: Ok, Thanks for explanation. So this shouldnt be a problem in most cases. But it might be a little messy when you have a multi-language site with i18n. In that case you would need to add multiple (almost) identical content types: all with same properties but with different labels, right? Shouldnt be the labels translatable and only the machine-readable name fixed? Otherwise it is very difficult (or even impossible?) to update a multi-lingual site from 4.7. I guess there is no feature to convert a bunch of nodes to a different content type, right? So one would need to create new content types (one for each language) and move existing nodes into nodes of the newly created (language-specific) content types manually ... (In 4.7 all languages were sharing e.g. the 'page' type which labels were translatable).
Comment #34
Steven CreditAttribution: Steven commentedprofix: i18n is another concern completely. Drupal does not support internationalization of content or variables out of the box, thei18n module has to provide this.
I tested the patch with and without a .po file, both english and other locale, and it works fine. Good job.
Committed to HEAD.
Comment #35
(not verified) CreditAttribution: commentedComment #36
Andrew Answer CreditAttribution: Andrew Answer commentedSee also this http://drupal.org/node/735466 and this http://drupal.org/node/735468 for D6.