nnjeim / world

A Laravel package which provides a list of the countries, states, cities, currencies, timezones and languages.
MIT License
737 stars 104 forks source link

Nationality & Official languages #91

Closed Sicklou closed 4 weeks ago

Sicklou commented 1 month ago

Hi,

I think the package is awesome, but I was also looking for nationality (like if you are born in France, the nationality is "French"). And also the official languages of the countries.

I'm ok to make a PR. But before, is it ok for you to add these two new information ?

Thank you for the package :)

nnjeim commented 1 month ago

@Sicklou Thank you for your input. However please take into count the multiple locales that are supported as of now. it might be a lot of work here. Do you have a source for the data that need to be added?

'accepted_locales' => [
        'ar',
        'bn',
        'br',
        'de',
        'en',
        'es',
        'fr',
        'hr',
        'it',
        'ja',
        'kr',
        'nl',
        'pl',
        'pt',
        'ro',
        'ru',
        'tr',
        'zh',
    ],
Sicklou commented 1 month ago

Using the Google Translate API with a python script in order to retrieve every translation ?

And where should I put the translation ? in the lang folder as "nationality.php" ?

nnjeim commented 1 month ago

i am not sure about the placement of this needed field. I would rather suggest you fork the repository and try to make it work on your end first. I would help you in the re-integration when you are done. this thing is that the countries.json file should be the source. in your case all the nationalities should be translated to all the supported locales. try to look at the translation of the countries names php files. it might inspire you how you would like to do it

Sicklou commented 1 month ago

Thanks for the reply.

I just forked the project. But I'm not sure of how I can test it. Did I need to do it as a standalone ? or inside a Laravel test app ?

As a standalone, tests doesn't work. I'm a little confused about how I can work on the package.

nnjeim commented 1 month ago

Thanks for the reply.

I just forked the project. But I'm not sure of how I can test it. Did I need to do it as a standalone ? or inside a Laravel test app ?

As a standalone, tests doesn't work. I'm a little confused about how I can work on the package.

Hi again, I personally develop the package as below. 1- install laravel app 2- create a folder where the name represents the 1st level domain name. in my case it is nnjeim 3- clone the repository inside nnjeim it will create the folder world where all the files are present 4- you need to modify the package composer.json to reflect your new domain names.

{
    "name": "nnjeim/world",
    "description": "Laravel countries, states, cities and currencies",
    "keywords": [
        "laravel",
        "lumen",
        "countries",
        "cities",
        "states",
        "timezones",
        "currencies"
    ],
    "homepage": "https://github.com/nnjeim/world.git",
    "license": "MIT",
    "type": "laravel-package",
    "authors": [
        {
            "name": "Najm Njeim",
            "email": "najm@njeim.net",
            "role": "Developer"
        }
    ],
    "require": {
        "php": ">=7.4"
    },
    "require-dev": {
        "orchestra/testbench": ">=v4.0.0",
        "phpunit/phpunit": ">=8.5.8"
    },
    "autoload": {
        "psr-4": {
            "Nnjeim\\World\\": "src/",
            "Nnjeim\\World\\Database\\Seeders\\": "src/Database/Seeders/"
        }
    },
    "autoload-dev": {
        "psr-4": {
            "Nnjeim\\World\\Tests\\": "tests/"
        }
    },
    "scripts": {
        "test": "vendor/bin/phpunit",
        "test-coverage": "vendor/bin/phpunit --coverage-html coverage"
    },
    "config": {
        "sort-packages": true
    },
    "extra": {
        "laravel": {
            "providers": [
                "Nnjeim\\World\\WorldServiceProvider"
            ],
            "aliases": {
                "Country": "Nnjeim\\World\\World"
            }
        }
    },
    "minimum-stability": "dev",
    "prefer-stable": true
}

5- In laravel's main composer.json i have added the below

 "repositories": [
        {
            "type": "path",
            "url": "./nnjeim/world"
        },
    ]
6- finally you need to run composer update at the root of the laravel's app to update all the above