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

MOB-76 Update logic for exporting copies for JS #63

Open
wants to merge 4 commits into
base: pv/MOB-80-update-dependency-versions
Choose a base branch
from

Conversation

pankajvaghela
Copy link

@pankajvaghela pankajvaghela commented Dec 8, 2022

Update logic for exporting copies for JS

Before copies were exported as 1-on-1 mapping like :

{
  "Basket.EditBasket.AddToDeliveryCurrentDeliverySection.Subtitle.COPY": "%1$s Produkte",
   //...
}

With this change, copies will be exported as JSON object :

{
  "Basket": {
    "EditBasket": {
      "AddToDeliveryCurrentDeliverySection": {
        "Subtitle": {
          "COPY": "%1$s Produkt"
        },
     }
   }
}

JIRA Ticket :
https://picnic.atlassian.net/browse/MOB-76

@pankajvaghela pankajvaghela force-pushed the pv/MOB-76-update-logic-for-exporting-copies-for-js branch from f235295 to f1e3f9f Compare December 9, 2022 10:29
@pankajvaghela pankajvaghela changed the base branch from v2.0.1 to pv/MOB-80-update-dependency-versions December 9, 2022 10:56
const { groupByKey } = require("../utils/arrayUtils");
const { flatten } = require("../utils/arrayUtils");
const Handlebars = require("handlebars");
const LodashUpdateWith = require("lodash.updatewith");

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A nit, shouldn't it be lowercase?

@@ -43,6 +44,7 @@ const renderLocalizationView = (view, outputType, language, basePath) => {
return localizationTemplate(outputType)
.map((source) => Handlebars.compile(source))
.map((template) => template(view))
.map((renderedTemplate) => postTemplateRenderFormatting(renderedTemplate, outputType))

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of postTemplateRenderFormatting can we rename it to something indicating what this function does? something like unflattenJson or something.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then it's very specific. In this function, we could be doing different things based on output mode,

Copy link

@pooyahrtn pooyahrtn Dec 13, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we could be doing different things based on output mode

Then probably it's against the "single responsibility" principle :D

Copy link
Author

@pankajvaghela pankajvaghela Dec 13, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ain't it single resposibility, If the responsibility is "postProcessing", whatever that means, based on outputType? o_O

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with @pooyahrtn, let's be explicit about what the function is doing. If we ever need more complicated post-processing steps, we can always change the function name later on.

@@ -15,7 +15,7 @@ const accessiblityKeywords = {
VALUE: "VALUE",
};

const outputType = {
const outputTypes = {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd say the previous name wasn't that bad, and I would rather keep it to make it easier later to read the git changes.

Copy link
Author

@pankajvaghela pankajvaghela Dec 13, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -43,6 +44,7 @@ const renderLocalizationView = (view, outputType, language, basePath) => {
return localizationTemplate(outputType)
.map((source) => Handlebars.compile(source))
.map((template) => template(view))
.map((renderedTemplate) => postTemplateRenderFormatting(renderedTemplate, outputType))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with @pooyahrtn, let's be explicit about what the function is doing. If we ever need more complicated post-processing steps, we can always change the function name later on.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

4 participants