Could it be possible to pass the originally provided strings via the t() function ? As I don't really need i18n, and my default language is french, non-english users don't really need english strings.

Each time variable_get('pathauto_ignore_words', PATHAUTO_IGNORE_WORDS); is called should be replaced by variable_get('pathauto_ignore_words', t(PATHAUTO_IGNORE_WORDS));

Comments

dave reid’s picture

So wouldn't you just edit the textfield at admin/config/search/path/settings to use french words then?

Freso’s picture

Category: task » feature
Status: Active » Closed (won't fix)

http://api.drupal.org/api/drupal/includes--bootstrap.inc/function/t/7 says:

You should never use t() to translate variables, [...]

So no, this will not happen. As Dave said, simply change the words in your local setup. For multilingual sites, the Internationalization suite has a module for translating site variables, including the "Strings to remove" one.

SebCorbin’s picture

Status: Active » Closed (won't fix)

Firstly, this is not a variable, it's a constant. So it can be translated, as says in your link :

It is especially important never to call t($user_text); , where $user_text is some text that a user entered

A constant is defined by the developer, no user-entered text.

And secondly, when I'm installing Pathauto on my french site, I hope to see french words removed (I mostly don't care about english ones) without being obliged to configure this every time I build a site.

SebCorbin’s picture

Status: Closed (won't fix) » Active
dave reid’s picture

Status: Closed (won't fix) » Fixed

It *is* a variable. Hence variable_get() is used. You are able to change the value of this variable at admin/config/search/path/settings. Trust me, you can.

SebCorbin’s picture

Status: Fixed » Active

(please let's discuss this without changing status... for now)

I know I can change the value, but I'm requesting this for localization matter, I've run a search on Pathauto issue queue and found many topic related to this problem (with italians requesting to have their default words too):
- internationalization (i18n) must not be a dependency to do this, as it's not part of traditional localization (l10n)
- your module is not fully translated because of this default string

If you consider you cannot use t() inside variable_get(), consider using it in define() then. What's wrong with that?

dave reid’s picture

You cannot use t() with define(). The item has to be a string or numeric value only, and cannot be the return value of a function.

SebCorbin’s picture

This constant is only used twice if I remember correctly, would it be possible to have it inlined?

dave reid’s picture

The other problem for this is this string shouldn't be translated per say, it's the list of the language's short words that do not have meaning - they may not all translated 100% from English to the desired language, or the language may have additional words that should be ignored.

SebCorbin’s picture

Status: Active » Closed (won't fix)

Ok, you got it, we're in a dead end, I'll always have this module 99% translated...

hanno’s picture

Issue tags: +l10n

bump. See this issue on several Dutch sites, where some words disappear in the alias while others stay and the owners are unaware. It would be better for localisation to make this string translatable. An alternative would be that the default of the field is blank and have the words as suggestions in the description of the field, and not as default value.

@Dave Is there a reason that a constant is used and not a variable_set() in pathauto_install()?

pathauto_install()
+variable_set('pathauto_ignore_words', t('a, an, as, at, before, but, by, for, from, is, in, into, like, of, off, on, onto, per, since, than, the, this, that, to, up, via, with'));
ludo.r’s picture

For multilingual sites, the Internationalization suite has a module for translating site variables, including the "Strings to remove" one.

Could someone tell me where to find this?

I can't find it in admin/config/regional/i18n/variable.

Freso’s picture

The other problem for this is this string shouldn't be translated per say, it's the list of the language's short words that do not have meaning - they may not all translated 100% from English to the desired language, or the language may have additional words that should be ignored.

Which doesn't mean at all that the string couldn't be a candidate for translating. Translation, or in this case: localisation, does not mean mapping each word 1:1. It's taking the essence/meaning of a given string and convert it to make sense in the target language/locale. A string of small commonly used words that should likely not be used in a path alias which is overly English-ish would be a good candidate for localisation.

However, as has been said elsewhere in this issue, there are two good ways to do just this, depending on the site in question (whether it be mono- or multi-lingual).

@dolu:
You can read about variable translation on https://drupal.org/node/1113374 - the variable in question is "pathauto_ignore_words".

ludo.r’s picture

@Freso:
Thanks for pointing me to this page. That's exactly where I expected to find this variable, however it is not available.

Am I missing something?
I'm using pathauto 7.x-1.2

hanno’s picture

@Freso Still an interesting discussion. In the API is indeed mentioned that you shouldn't use t() for variables, but mentioned are php variables (t($text)), not a Drupal persistent variable default. Translation of the default of Drupal variables is done in Drupal core itself as well, for example in
http://api.drupal.org/api/drupal/modules!system!system.admin.inc/functio...
'#default_value' => variable_get('maintenance_mode_message', t('@site is currently under maintenance. We should be back shortly. Thank you for your patience.', array('@site' => variable_get('site_name', 'Drupal')))),
The exact same logic to add t() for the default value of the variable we could use in

  $form['pathauto_ignore_words'] = array(
    '#type' => 'textarea',
    '#title' => t('Strings to Remove'),
    '#default_value' => variable_get('pathauto_ignore_words', PATHAUTO_IGNORE_WORDS),
    '#description' => t('Words to strip out of the URL alias, separated by commas. Do not use this to remove punctuation.'),
    '#wysiwyg' => FALSE,
  );

This way, the variable is translatable, and, when this module gets installed, gets directly the right language, without the need for i18n. See also a discussion in external links module #672500: Translatable Variable Defaults

pbouchereau’s picture

Issue summary: View changes
Status: Closed (won't fix) » Closed (duplicate)
pbouchereau’s picture