Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Fix language file names having to be unique on a project basis. #618

Closed
wants to merge 1 commit into from

4 participants

@Bogdanp

Without this you would be unable to have two different languages with the same _lang files in them. For example:

If you had the following folder structure:

application/language
  en/general_lang.php
  de/general_lang.php

If you were to load the English general_lang.php file as default and then try to load the German one on a per-user basis the file wouldn't get loaded because the load function would only check the filename and ignore its idiom. This patch fixes that issue.

@Bogdanp Bogdanp Fixes language file names having to be unique on a project basis.

Without this you would be unable to have two different languages with the same _lang files in them. For example:

If you had the following folder structure:
  application/language:
    en/general_lang.php
    de/general_lang.php

If you were to load the en general_lang file as default and then try to load the German one on a per-user basis the file wouldn't get loaded because the load function would only check the filename and ignore its 'idiom'. This patch fixes that issue.
d8b1a02
@philsturgeon

This is not so much a bug but intended behaviour. If you load two language files with the same name then you'll end up with a mix, which for you in your specific application may bring some lovely "translation fallback" functionality, but for others would be unexpected behavior.

We need to think about the pro's and con's of this one. I have no idea.

@Bogdanp

The thing is, I found this to be unexpected behavior and I had to look through the source code to find why what I was trying to do wasn't working. There should at least be a mention in the documentation about how this works.

@petsagouris

I too consider merging language arrays expected behavior too. This is how it should normally work. (this is how gettext works too)

Having fallback translation strings helps a lot with semi-complete translations. I can't think of any case that having the current functionality useful.

@narfbg
Owner

#993

Edit: Sorry, misunderstood the topic. :)

@narfbg narfbg closed this
@narfbg narfbg reopened this
@narfbg
Owner

... or not. #993 does indeed fix this.

@narfbg narfbg closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Oct 25, 2011
  1. @Bogdanp

    Fixes language file names having to be unique on a project basis.

    Bogdanp authored
    
    Without this you would be unable to have two different languages with the same _lang files in them. For example:
    
    If you had the following folder structure:
      application/language:
        en/general_lang.php
        de/general_lang.php
    
    If you were to load the en general_lang file as default and then try to load the German one on a per-user basis the file wouldn't get loaded because the load function would only check the filename and ignore its 'idiom'. This patch fixes that issue.
This page is out of date. Refresh to see the latest.
Showing with 3 additions and 2 deletions.
  1. +3 −2 system/core/Lang.php
View
5 system/core/Lang.php
@@ -84,8 +84,9 @@ function load($langfile = '', $idiom = '', $return = FALSE, $add_suffix = TRUE,
}
$langfile .= '.php';
+ $langname = "$idiom/$langfile";
- if (in_array($langfile, $this->is_loaded, TRUE))
+ if (in_array($langname, $this->is_loaded, TRUE))
{
return;
}
@@ -135,7 +136,7 @@ function load($langfile = '', $idiom = '', $return = FALSE, $add_suffix = TRUE,
return $lang;
}
- $this->is_loaded[] = $langfile;
+ $this->is_loaded[] = $langname;
$this->language = $this->language + $lang;
unset($lang);
Something went wrong with that request. Please try again.