0

Is it possible to override json data under symfony/src/Symfony/Component/Intl/Resources? For example, in data/languages/en.json I would like to change "zh": "Chinese" to be more specifically "zh": "Mandarin Chinese".

nurikabe
  • 3,802
  • 2
  • 31
  • 39

2 Answers2

1

I'm not the pro with Symfony, but i get the same question and for me, i did find a workaround that works. I didn't use it in forms, i use it only to display.

I did create a Model called Country for accessing and manipulating the RegionBundle:

namespace AppBundle\Model;

use Symfony\Component\Intl\Data\Bundle\Reader\BufferedBundleReader;
use Symfony\Component\Intl\Data\Bundle\Reader\BundleEntryReader;
use Symfony\Component\Intl\Data\Bundle\Reader\JsonBundleReader;
use Symfony\Component\Intl\Intl;
use Symfony\Component\Intl\ResourceBundle\RegionBundle;


class Country
{

    public static function getCountryName($countryCode, $locale='de')
    {
        $test = new RegionBundle(
            __DIR__.'/../Resources/Intl/data'.'/'.Intl::REGION_DIR,
            new BundleEntryReader(new BufferedBundleReader(
                new JsonBundleReader(),
                Intl::BUFFER_SIZE
            )),
            Intl::getLocaleBundle()
        );

        return $test->getCountryName($countryCode, $locale);

    }

}

And from a controller, i can call them with:

Country::getCountryName('AF')

Maybe this is not the "state of the art" approach, but i was spending hours of searching another solution - but dont find any approach that is useable for me.

rebru
  • 519
  • 3
  • 10
0

Did you tried to copy that file under app/Resources/data/languages/en.json than change it over there?

Also don't forget to clear cache

MustafaB
  • 212
  • 3
  • 10