GithubHelp home page GithubHelp logo

boxblinkracer / phpunuhi Goto Github PK

View Code? Open in Web Editor NEW
72.0 3.0 5.0 2.96 MB

PHPUnuhi - The easy composable framework to validate and manage translations

License: MIT License

PHP 96.95% Shell 0.04% Makefile 3.00% Twig 0.01%
internationalization localization shopware6 translation-management translations

phpunuhi's People

Contributors

ahoffmeyer avatar boxblinkracer avatar joshuabehrens avatar matthiashamacher avatar mjosef89 avatar tumtum avatar xabbuh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

phpunuhi's Issues

Command to find translation files

it would be good to have a command to find translation files that are not yet added to the config.
maybe with regex and/or excludedDirectory mode?

Add "basePath" for locale list

it would be great to have the option to specify a basePath for all locales

<locales basePath="/my-path/translations">
    <locale name="en">%basePath%/en.ini</locale>
    <locale name="de">%basePath%/de.ini</locale>
</locales>

Question about Shopware6 storage and project scope

Hi there,

first of all, thanks for this nice framework and sorry for the wall of text.
I have looked at this specifically with a focus on Shopware 6 entities and have a few questions/remarks.

There are problems with null-values when using the "shopware6" format . However, these can always occur, e.g. if a product only have minimal data yet. From my point of view, this is a bug, or am I missing something?

Fatal error: Uncaught TypeError: PHPUnuhi\Bundles\Storage\Shopware6\Service\TranslationLoader::isBinary(): Argument #1 ($str) must be of type string, null given, called in /app/vendor/boxblinkracer/phpunuhi/src/Bundles/Storage/Shopware6/Service/TranslationLoader.php on line 167 and defined in /app/vendor/boxblinkracer/phpunuhi/src/Traits/BinaryTrait.php:38

I haven't tested it extensively yet, but it seems to be sufficient to convert null values to empty strings at this point.

If the "translate" command is called with the option "--source", an attempt is still made to translate missing translations of the source language itself. However, this will always fail in this case as $existingData = $set->findAnyExistingTranslation($currentID, $sourceLocale); will throw a TranslationNotFoundException.

If the source language is not skipped in the loop, if a text is missing you get an error message for each of the other languages plus additionally for the source language. I think this is unnecessary and the source language could be skipped in this case.

My intended use is mainly related to the translation of missing texts from Shopware entities. In my opinion, however, the logic here should be able to deviate from the usual snippets.

Using the product entity as an example:
Based on the table structure, there are already fixed fields that Shopware supplies, but it may be that some of them are not needed in a project. Others could be optional and only be filled for some products.

As long as something is not available in the main language of the shop, it should not be considered "missing" in my case.

I would like the following behavior for shopware entities when the "translate" command is executed with option "--source":

If a value is missing in the "--source" language e.g. "description" skip it.
Otherwise try to translate if for all other languages where a translation is missing.

As far as I could tell after trying around a bit, this does not seem to be possible at the moment, as the processing is always independent of the source (storage) and this special case for Shopware entities can therefore not be implemented without further ado.

The framework could certainly be extended in this regard, but I am unsure whether its a good idea to bend the framework in this direction, so I wanted to ask whats your opinion is about this use-case.

Allow List for some keys and case styles

Sometimes you are forced to have specific keys written in a specific case style although you just dont like it.

in that case you dont want to break your rules
but rather add some kind of "allow list" for some keys to let them be as they are :)

Suppress translation from validate:all command

The php vendor/bin/phpunuhi validate:all command validates all translations. Is there any possibility of ignoring or suppressing some snippets from this check?

Several translations have been intentionally left blank. For example shopBE.general.socials.pinterestLink has no translation for en-GB but has a translation for it-IT.

image

SW6 Storage Entity Snippets

add "entity" for snippets in the database

should be the same sw6 storage format, only with a fake "entity" snippet that behaves a bit different

Add XML Storage

the tricky thing with XML storages is that there needs to be some kind of mapping or xsd,
because xml structures are (always) different.

anyone an idea?

Add Support for categories and shopping experiences in shopware 6 storage format

Hi,

In Shopware 6, in addition to the translations of various entities (usually in the [...]_translation table), there is also the option of assigning categories and products layouts from the shopping experiences area. As soon as this has been done, you have the option of storing various other fields with content in the respective language in each category and each product. This data is stored for categories, for example, in the category_translation table in the slot_config field as json.

Here we have the challenge that this data, preferably in CSV format, should also be sent to an external translator.

It would therefore be very helpful if there was a way to export and import this data with PHPUnuhi.

Storage pattern feature

it would be great to define a pattern for the key. like foo-bar or fooBar.
this could be defined as regex on storages

Support Magento2 as Storage Format

Hi there

Update: the initial question is no longer relevant now that we've changed the title in this issue

Just playing around, we are using csv files for translations (used by Magento2 e-commerce) which this tool doesn't support yet, but out of curiosity I quickly converted them to json to be able to play around a bit with this tool to see how well it works and if it would be useful for us or not.

But I noticed something strange when dots (.) exist in the translations:

Here's an example json file:

{
    "An unknown error occurred.": "Een onbekende fout is opgetreden.",
    "Searching...": "Zoeken..."
}

After running vendor/bin/phpunuhi fix:structure it turns this json into something very strange:

{
    "An unknown error occurred": {
        "": "Een onbekende fout is opgetreden."
    },
    "Searching": {
        "": {
            "": {
                "": "Zoeken..."
            }
        }
    }
}

It looks like it converts a . character into a new key-value each time, which is kind of unexpected.

Or am I missing some configuration setting somehow?

Thanks!

Duplicate Content check can cause problems in specific languages

We currently have the problem that we have a translation for Country, like USA or Germany, and Country, the style or synonyme for Countryside. This causes problems with the duplicate check as it fails only in the english translations not i.e. the german as we have Land and Country there. As they mean something different by context and are spelled differently in german we cannot aggregate them to one key. This is probably not the only word and langauge where this can cause problems.

For now, which fixes this problem in our case, the filter logic for the key would be suffice so I've implemented it for yaml: #35

But in any other case this maybe would not be enough so I think we need to think about another possibility to fix this issue. My first idea would be to have a whitelist option for the duplicate content rule. Probably you also need to make it language specific as you want Country twice in english but only once in german.

Would that be a viable solution or are there any better ones? I'm happy to implement it but wanted your feedback first.

Allow imports of sub configuration files

It would be good to have the option to create separate configuration files
and import those in the main file

<translations>

     <import file="....."/>
     <import file="....."/>

    <set name..../>

</translations>

Plugin system

add option to add custom services at runtime. custom translators, storages and more

Placeholders in filenames

It would be great if the locale name could be used
as placeholder in the file path

sometimes folders AND the file name contain the locale, and this would be better for maintaining things

        <locales>
            <locale name="en-GB">./{locale}/xxxx/{locale}.json</locale>
        </locales>

Make translations node optional if imports are used

I would like to configure all my translation sets in sub-files and then import them into a main file. However, no extra set should be configured in the main file. This is currently not possible as the “translations” node is required.

Wrong shebang in bin script

Hi guys

I've just started testing this package on my system (macOS) and noticed I can't run vendor/bin/phpunuhi, I get:

/usr/bin/php: bad interpreter: No such file or directory

This is because the shebang at the top of the bin script is hardcoded instead of trying to find the correct php binary from the environment.

So the line:

#!/usr/bin/php

Should be replaced with:

#!/usr/bin/env php

This is also how other php packages do this, for example:

Thanks!

Wildcards for filenames

it would be great to have a

"*" wildcard that merges all found files

        <locales>
            <locale name="en-dev">./**/*.json</locale>
        </locales>

this helps if maaaany json files exist.
Keys and their neting path need to be unique anyway..(if one wants to use this feature)
so a recursive merge before comparing results should be fine.

only filenames cannot be displayed in that case

only export empty translations

it would be good to only export empty translations
and just skip existing ones

this would be easier for people who add the last missing ones

please double check that an import only overwrites the provided one...so that nothing is lost accidentally

Automatically remove unused keys

There might be a use case where you want to remove keys from all files

so maybe a separate command
or something like fix:structure but only for destructive purposes

or maybe fix:structure with a provided base-locale file as structure-template?

Protect markers

If you have translation markers e.g. The name of the product is %productName%.
The placeholder %productName% should be protected from translation via translation services.

Shopware 6 - State machine, sorting options, and salutations translations

Hi,

This is a feature request for non-snippet translations. Currently in Shopware 6 (6.6) not all translations are editable with the use of snippets. The following three sections are connected to the frontend for customers to see by default.

  • For the State Machine they aren't even editable in the admin.
    Located in the state_machine_state_translation table
  • The sorting options can be edited in the admin: Settings->Shop->Products
    Located in the product_sorting_translation table
  • The salutations can be edited in the admin: Settings->Shop->Salutations
    Located in the salutation_translation table

There are more translations not using snippets, tables with [...]_translation. But those are data driven for example the categories and shopping experiences.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.