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

[Shopify] Add Translations Export to Products and Variants #26216

Merged
merged 8 commits into from
Aug 19, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions Apps/W1/Shopify/app/src/Base/Enums/ShpfyResourceType.Enum.al
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
namespace Microsoft.Integration.Shopify;
tinestaric marked this conversation as resolved.
Show resolved Hide resolved

enum 30153 "Shpfy Resource Type" implements "Shpfy ICreate Translation"
{
Access = Internal;
Caption = 'Shopify Resource Type';
Extensible = false;

value(0; Product)
{
Caption = 'Product';
Implementation = "Shpfy ICreate Translation" = "Shpfy Create Transl. Product";
}

value(1; ProductVariant)
{
Caption = 'Product Variant';
Implementation = "Shpfy ICreate Translation" = "Shpfy Create Transl. Variant";
}
}
58 changes: 58 additions & 0 deletions Apps/W1/Shopify/app/src/Base/Pages/ShpfyLanguages.Page.al
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
namespace Microsoft.Integration.Shopify;
tinestaric marked this conversation as resolved.
Show resolved Hide resolved

page 30161 "Shpfy Languages"
{
ApplicationArea = All;
Caption = 'Shpfy Languages';
PageType = List;
SourceTable = "Shpfy Language";
UsageCategory = None;
InsertAllowed = false;
DeleteAllowed = false;

layout
{
area(content)
{
repeater(General)
{
field(Locale; Rec.Locale)
{
ToolTip = 'Specifies the shop locale to sync translations.';
}
field("Language Code"; Rec."Language Code")
{
ToolTip = 'Specifies the language code for the locale.';
}
field("Sync Translations"; Rec."Sync Translations")
{
ToolTip = 'Specifies if the translations should be synced for this locale.';
}
}
}
}

actions
{
area(processing)
{
action(Refresh)
{
ApplicationArea = All;
Caption = 'Refresh';
Promoted = true;
PromotedOnly = true;
PromotedCategory = Process;
Image = Refresh;
ToolTip = 'Refreshes the list of Shopify languages.';

trigger OnAction()
var
ShpfyTranslationAPI: Codeunit "Shpfy Translation API";
begin
ShpfyTranslationAPI.PullLanguages(CopyStr(Rec.GetFilter("Shop Code"), 1, 20));
end;
}
}
}
}
15 changes: 14 additions & 1 deletion Apps/W1/Shopify/app/src/Base/Pages/ShpfyShopCard.Page.al
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ page 30101 "Shpfy Shop Card"
#if not CLEAN23
if BulkOperationMgt.IsBulkOperationFeatureEnabled() then
#endif
BulkOperationMgt.EnableBulkOperations(Rec);
BulkOperationMgt.EnableBulkOperations(Rec);
Rec."B2B Enabled" := Rec.GetB2BEnabled();
FeatureTelemetry.LogUptake('0000HUT', 'Shopify', Enum::"Feature Uptake Status"::"Set up");
end;
Expand Down Expand Up @@ -793,6 +793,19 @@ page 30101 "Shpfy Shop Card"
ToolTip = 'View a list of Shopify catalogs for the shop.';
Visible = Rec."B2B Enabled";
}
action(Languages)
{
ApplicationArea = All;
Caption = 'Languages';
Image = Translations;
Promoted = true;
PromotedCategory = Category4;
PromotedIsBig = true;
PromotedOnly = true;
RunObject = Page "Shpfy Languages";
RunPageLink = "Shop Code" = field(Code);
ToolTip = 'View a list of Shopify Languages for the shop.';
}
}
area(Processing)
{
Expand Down
72 changes: 72 additions & 0 deletions Apps/W1/Shopify/app/src/Base/Tables/ShpfyLanguage.Table.al
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
namespace Microsoft.Integration.Shopify;
tinestaric marked this conversation as resolved.
Show resolved Hide resolved

using System.Globalization;

table 30154 "Shpfy Language"
{
Caption = 'Shopify Language';
DataClassification = CustomerContent;

fields
{
field(1; "Shop Code"; Code[20])
{
Caption = 'Shop Code';
DataClassification = CustomerContent;
Editable = false;
TableRelation = "Shpfy Shop";
}

field(2; Locale; text[2])
onbuyuka marked this conversation as resolved.
Show resolved Hide resolved
{
Caption = 'Locale';
DataClassification = SystemMetadata;
Editable = false;
}

field(3; "Sync Translations"; Boolean)
{
Caption = 'Sync translations';
DataClassification = CustomerContent;

trigger OnValidate()
begin
Rec.TestField("Language Code");
end;
}
field(4; "Language Code"; Code[10])
{
Caption = 'Language Code';
TableRelation = Language;
DataClassification = CustomerContent;

trigger OnValidate()
begin
onbuyuka marked this conversation as resolved.
Show resolved Hide resolved
Rec.TestField("Sync Translations", false);
end;
}
}

keys
{
key(PK; "Shop Code", Locale)
{
Clustered = true;
}
}

/// <summary>
/// Adds a language to the table.
/// </summary>
/// <param name="Shop">Shop the language belongs to.</param>
/// <param name="LocaleText">Locale of the language.</param>
internal procedure AddLanguage(Shop: Record "Shpfy Shop"; NewLocale: Text[2])
var
ShpfyLanguage: Record "Shpfy Language";
begin
ShpfyLanguage.Init();
ShpfyLanguage."Shop Code" := Shop.Code;
ShpfyLanguage.Locale := NewLocale;
ShpfyLanguage.Insert(true);
end;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
namespace Microsoft.Integration.Shopify;

codeunit 30168 "Shpfy GQL ShopLocales" implements "Shpfy IGraphQL"
{

internal procedure GetGraphQL(): Text
begin
exit('{"query":"{ shopLocales { locale primary published }}"}');
end;

internal procedure GetExpectedCost(): Integer
begin
exit(3);
end;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
namespace Microsoft.Integration.Shopify;

codeunit 30311 "Shpfy GQL TranslResource" implements "Shpfy IGraphQL"
{

internal procedure GetGraphQL(): Text
begin
exit('{"query":"{ translatableResource(resourceId: \"gid://shopify/{{ResourceType}}/{{ResourceId}}\") { resourceId translatableContent {key value digest locale} }}"}');
end;

internal procedure GetExpectedCost(): Integer
begin
exit(3);
end;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
namespace Microsoft.Integration.Shopify;

codeunit 30159 "Shpfy GQL TranslationsRegister" implements "Shpfy IGraphQL"
{

internal procedure GetGraphQL(): Text
begin
exit('{"query": "mutation { translationsRegister(resourceId: \"gid://shopify/{{ResourceType}}/{{ResourceId}}\", translations: [{{Translations}}]) { userErrors {field, message}}}"}');
end;

internal procedure GetExpectedCost(): Integer
begin
exit(50);
end;
}
15 changes: 15 additions & 0 deletions Apps/W1/Shopify/app/src/GraphQL/Enums/ShpfyGraphQLType.Enum.al
Original file line number Diff line number Diff line change
Expand Up @@ -400,4 +400,19 @@ enum 30111 "Shpfy GraphQL Type" implements "Shpfy IGraphQL"
Caption = 'Get Next Catalog Products';
Implementation = "Shpfy IGraphQL" = "Shpfy GQL NextCatalogProducts";
}
value(78; TranslationsRegister)
{
Caption = 'Translations Register';
Implementation = "Shpfy IGraphQL" = "Shpfy GQL TranslationsRegister";
}
value(79; ShopLocales)
{
Caption = 'Shop Locales';
Implementation = "Shpfy IGraphQL" = "Shpfy GQL ShopLocales";
}
value(80; GetTranslResource)
{
Caption = 'Get Transl Resource';
Implementation = "Shpfy IGraphQL" = "Shpfy GQL TranslResource";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ codeunit 30199 "Shpfy Authentication Mgt."

var
// https://shopify.dev/api/usage/access-scopes
ScopeTxt: Label 'write_orders,read_all_orders,write_assigned_fulfillment_orders,read_checkouts,write_customers,read_discounts,write_files,write_merchant_managed_fulfillment_orders,write_fulfillments,write_inventory,read_locations,read_payment_terms,write_products,write_shipping,read_shopify_payments_disputes,read_shopify_payments_payouts,write_returns,write_translations,write_third_party_fulfillment_orders,write_order_edits,write_companies,write_publications', Locked = true;
ScopeTxt: Label 'write_orders,read_all_orders,write_assigned_fulfillment_orders,read_checkouts,write_customers,read_discounts,write_files,write_merchant_managed_fulfillment_orders,write_fulfillments,write_inventory,read_locations,read_payment_terms,write_products,write_shipping,read_shopify_payments_disputes,read_shopify_payments_payouts,write_returns,write_translations,write_third_party_fulfillment_orders,write_order_edits,write_companies,write_publications,read_locales', Locked = true;
ShopifyAPIKeyAKVSecretNameLbl: Label 'ShopifyApiKey', Locked = true;
ShopifyAPISecretAKVSecretNameLbl: Label 'ShopifyApiSecret', Locked = true;
MissingAPIKeyTelemetryTxt: Label 'The api key has not been initialized.', Locked = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ permissionset 30102 "Shpfy - Edit"
tabledata "Shpfy Gift Card" = IMD,
tabledata "Shpfy Initial Import Line" = imd,
tabledata "Shpfy Inventory Item" = IMD,
tabledata "Shpfy Language" = IMD,
tabledata "Shpfy Log Entry" = IMD,
tabledata "Shpfy Metafield" = IMD,
tabledata "Shpfy Refund Header" = IMD,
Expand Down Expand Up @@ -69,5 +70,6 @@ permissionset 30102 "Shpfy - Edit"
tabledata "Shpfy Templates Warnings" = IMD,
#endif
tabledata "Shpfy Transaction Gateway" = IMD,
tabledata "Shpfy Translation" = IMD,
tabledata "Shpfy Variant" = IMD;
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ permissionset 30100 "Shpfy - Read"
tabledata "Shpfy Gift Card" = R,
tabledata "Shpfy Initial Import Line" = r,
tabledata "Shpfy Inventory Item" = R,
tabledata "Shpfy Language" = R,
tabledata "Shpfy Log Entry" = R,
tabledata "Shpfy Metafield" = R,
tabledata "Shpfy Order Attribute" = R,
Expand Down Expand Up @@ -69,6 +70,7 @@ permissionset 30100 "Shpfy - Read"
tabledata "Shpfy Templates Warnings" = R,
#endif
tabledata "Shpfy Transaction Gateway" = R,
tabledata "Shpfy Translation" = R,
tabledata "Shpfy Variant" = R;
}
#pragma warning restore AS0090, AS0049
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ codeunit 30177 "Shpfy Product Events"
/// <param name="ItemNo">Parameter of type Code[20].</param>
/// <param name="ShopifyShop">Parameter of type Record "Shopify Shop".</param>
/// <param name="ProductBodyHtml">Parameter of type Text.</param>
internal procedure OnAfterCreateProductBodyHtml(ItemNo: Code[20]; ShopifyShop: Record "Shpfy Shop"; var ProductBodyHtml: Text)
/// <param name="LanguageCode">Parameter of type Code[10].</param>
internal procedure OnAfterCreateProductBodyHtml(ItemNo: Code[20]; ShopifyShop: Record "Shpfy Shop"; var ProductBodyHtml: Text; LanguageCode: Code[10])
begin
end;

Expand Down Expand Up @@ -147,7 +148,8 @@ codeunit 30177 "Shpfy Product Events"
/// <param name="ShopifyShop">Parameter of type Record "Shopify Shop".</param>
/// <param name="ProductBodyHtml">Parameter of type Text.</param>
/// <param name="Handled">Parameter of type Boolean.</param>
internal procedure OnBeforeCreateProductBodyHtml(ItemNo: Code[20]; ShopifyShop: Record "Shpfy Shop"; var ProductBodyHtml: Text; var Handled: Boolean)
/// <param name="LanguageCode">Parameter of type Code[10].</param>
internal procedure OnBeforeCreateProductBodyHtml(ItemNo: Code[20]; ShopifyShop: Record "Shpfy Shop"; var ProductBodyHtml: Text; var Handled: Boolean; LanguageCode: Code[10])
begin
end;

Expand Down
Loading
Loading