Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Add language support
  • No idea if this is the right place...

    Most of my pages are for german speaking people, so I rewrite some parts of the UI to be in german.

    Now, I was wondering if this could be possible to be done on creation of the files. Like oil reading the language-value in the app/.../config.php file and select the titles accordingly.

    I'm willing to do that, if someone gives me a general hint or advice for what to look for, so that I don't do anything to stupid.
  • HarroHarro
    Accepted Answer
    Ideally everything language dependent should be in language files, so you can swap just by switching the language set in the config. This is what the Lang class is for.

    All our applications have a multilingual interface using this mechanism.
  • Nice. I'll add a german version then.

    On that part: In uploaded.php: The error 'error_'.\Upload::UPLOAD_ERR_FORM_SIZE, it tells me 'The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form'. But is the file really uploaded? I mean, wouldn't that defeat the idea of having such a directive? Shouldn't it be called 'The file you wanted to upload...'?

    Giving it more thought: The language differences are much wider than just adapting the error messages and words, the grammar differs...
    For example:
      Session::set_flash('success', e('Eintrag #' . $id .' aktualisiert.'));


  • Perhaps, but it's the way PHP works. If the file exceeds the size defined in the php.ini, you won't be able to access it, and you'll get this error. I can imagine that it will abort the upload if this size is exceeded to avoid unneeded load on the server.

    For parameters in messages, I use sprintf() which allows you to position them where you want:

    Session::set_flash('success', e(sprintf(__('lang.message'), $id));

    where 'lang.message' is an entry in a lang file containing

    'message' => 'Eintrag #$1 aktualisiert.',
  • php.ini

    Both of these parameters need to be the same for it to work:

    ; Maximum allowed size for uploaded files.
    upload_max_filesize = 40M

    ; Must be greater than or equal to upload_max_filesize
    post_max_size = 40M

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion