Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add flexibility for object/initializer that is used for adding/updating copy in culture file #8

Closed
brandongregoryscott opened this issue Jun 9, 2021 · 0 comments · Fixed by #20
Labels
enhancement New feature or request

Comments

@brandongregoryscott
Copy link
Owner

brandongregoryscott commented Jun 9, 2021

Right now, the logic that finds the 'resources' object to insert or update key/values in is pretty tied to the structure in the README (ie, the literal initializer that is passed to LocalizationUtils.cultureFactory(...)

On a client project that this extension was primarily based off of, we recently got the first professionally translated file back and had to import the data. In an effort to keep future translation files smaller (sending over only the new or updated copy), we moved all of the keys and values that had changed into another object above the literal object that is passed to LocalizationUtils.cultureFactory(...).

This issue should investigate ways to ease the specificity of which object is pulled for inserting/updating keys. Perhaps the first literal object that has the key (if updating) or the last literal object (if adding). There may be an opportunity for a configuration setting to add control for this, too, though I'm not sure there's a use case other than the one described.

Example:

import { BaseSpanishSpain, Culture } from "andculturecode-javascript-core";
import CultureResources from "utilities/interfaces/culture-resources";
import LocalizationUtils from "utilities/localization-utils";

const ProfessionallyTranslatedSpanishSpain = {
    "aboutApp": "Acerca de {{appName}}",
    "acceptGroupInvitation-invitedByNameToJoin": "{{byName}} te invitó {{toJoin}}",
    "acceptGroupInvitation-invitedToJoin": "Has sido invitado {{toJoin}}",
    // ...
    "warnings-thisActionCannotBeUndone": "Esta acción no se puede deshacer.",
    "yellow": "Amarillo",
    "yesAction": "Sí, {{action}}",
    "you": "Tú",
    "yourItem": "Su {{item}}",
};

const SpanishSpain: Culture<CultureResources> = LocalizationUtils.cultureFactory(BaseSpanishSpain, {
    resources: {
        ...ProfessionallyTranslatedSpanishSpain,
        "admin": "Administración",
        "all": "todas",
        "allOfItem": "Todo {{item}}",
        "clearAll": "Limpiar todo",
        // ...
        "support-otherFormsOfContact_answer": "<0>Nuestro equipo de atención al cliente está disponible para ayudarlo {{supportHours}}. Si está fuera de nuestro horario comercial, envíenos un correo electrónico a <3></3> Y le responderemos en nuestro próximo día hábil.</0><1><strong>Teléfono</strong></1><2><0></0> (U.S. & Canada)</2><3><0>{{altPhone}}</0> (U.S. & Canada)</3><4><0></0> (Internacional)</4><5><0>{{mxPhone}}</0> (México)</5>",
        "support-otherFormsOfContact": "Otras formas de contacto.",
        "updatedItem": "Actualizado {{item}}.",
        "userRole": "rol del usuario",
    },
});

export default SpanishSpain;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant