1

I want to make translations in symfony using CsvFileLoader. I have written following code

    $file = __DIR__.'/file.csv';
    $translator = new Translator('fr', new MessageSelector());
    $translator->addLoader('csv', new CsvFileLoader());
    $translator->addResource('csv', $file, 'fr');
    $translator->setFallbackLocales(array('en'));
    $translator->trans('Hello'));

But I am not able to get the translation for given input.

1
  • can you post the content of the csv file? Commented Aug 3, 2017 at 12:14

1 Answer 1

1

I successfully run you code with the following csv file content:

"Hello";"Bonjour"

Take care of the default configuration of the CsvFileLoader class.

If you want to override you need to call the method setCsvControl passing various argument. From the API doc:

setCsvControl(string $delimiter = ';', string $enclosure = '"', string $escape = '\\')

Sets the delimiter, enclosure, and escape character for CSV.

Hope this help

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.