php-gettext / Gettext

PHP library to collect and manipulate gettext (.po, .mo, .php, .json, etc)
MIT License
687 stars 134 forks source link

JSON files - Undefined index "messages" #203

Closed odan closed 5 years ago

odan commented 5 years ago

I have some other json files without a "messages" element. This will print a lot of warnings if I parse my files:

Undefined index "messages" in MultidimensionalArrayTrait.php line 82.

I think a simple "empty" check would solve that issue:

if (empty($messages['messages'])) {
    return;
}
oscarotero commented 5 years ago

How do you create these json files? messages should exist always.

odan commented 5 years ago

These are JSON files that must not be analyzed, because I have to use the datatables.net component-specific translation files. Example: https://cdn.datatables.net/plug-ins/1.10.19/i18n/English.json

oscarotero commented 5 years ago

For plain json files, use the JsonDictionary extractor.

odan commented 5 years ago

Well, that's not what I'm trying to achieve. I don't want to find messages in this JSON files. The content of these files is static and only necessary for for the datatables.net component.

oscarotero commented 5 years ago

Sorry but now I'm confused. What do you need?

odan commented 5 years ago

I have Json files that are not intended for translation. The file extension is .json, but these files should be ignored if the content is not valid for the translation parser. I found a workaround for this issue. Thank you for your attention.