Languages and Identifiers
The three typed entry points and each original array view accept an optional language code:
| Constant | Value | Meaning |
|---|---|---|
Language::ENGLISH | 'en' | English, the default |
Language::NEPALI | 'ne' | Nepali, written in Devanagari |
Pass Language::NEPALI when starting a query; a relationship reached from one of its records stays in Nepali. The language also determines the values returned by name() and, for local levels, typeLabel(). type() uses a language-independent key from LocalLevelType.
use KodeFarmers\NepalData\Entities\Province;
use KodeFarmers\NepalData\Language;
$english = $data->provinces(Language::ENGLISH)->findOrFail(Province::MADHESH);
$nepali = $data->provinces(Language::NEPALI)->findOrFail(Province::MADHESH);
echo $english->name(), ' / ', $nepali->name(), PHP_EOL; // Madhesh / मधेश
'english', 'nepali', 'devanagari', and 'np' are not accepted v2 language codes. An unsupported value raises InvalidArgumentException. Laravel’s current application locale does not set the package language automatically.
Stable province and district IDs
Use Province::KARNALI, District::KASKI, and the other named constants for province and district lookups. These are integer package IDs, shared across English and Nepali. Use a province constant for whereProvince() and a district constant for whereDistrict().
IDs are scoped to their dataset. A province ID and a district ID can have the same integer value and refer to different places. Store the dataset alongside an ID if your application handles multiple record types. The package exposes no government administrative codes.
Prefer constants over comparisons on display names. The province in the example above is Madhesh in the typed English catalog but Madesh in some original arrays. The constant identifies the typed record without requiring the caller to account for different spellings. Constants can also be used to retrieve localized labels for the same province or district side by side.
Snapshot-specific local level IDs
Local level IDs are one-based positions in the selected language’s nested source snapshot. They are unique within that language’s local level catalog and retained when you filter or sort, but they are not durable identifiers across snapshots. English and Nepali local level IDs have no supported mapping.
Use a local level ID with the language in which you obtained it. Do not assume that fetching the same integer in the other language retrieves a translation. If you need a durable identifier for local levels in your own system, maintain your own key alongside the source and language you recorded. A name alone is not necessarily unique.
When exact spelling matters, search within the intended language and narrow to the known district. See Queries and Filters.