Skip to content

Commit

Permalink
Adjustments to translation texts and response type
Browse files Browse the repository at this point in the history
  • Loading branch information
volkanceylan committed Sep 18, 2024
1 parent 735d860 commit 1a23302
Show file tree
Hide file tree
Showing 7 changed files with 129 additions and 29 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ServiceRequest } from "@serenity-is/corelib";
import { ServiceResponse } from "@serenity-is/corelib";
import { TranslateTextOutput } from "./TranslateTextOutput";

export interface TranslateTextResponse extends ServiceRequest {
export interface TranslateTextResponse extends ServiceResponse {
Translations?: TranslateTextOutput[];
}
16 changes: 10 additions & 6 deletions src/Serenity.Extensions/Modules/ServerTypes/Texts.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { proxyTexts } from "@serenity-is/corelib";

namespace Serenity.Extensions.Texts {
namespace texts {

export declare namespace Db {

Expand Down Expand Up @@ -84,9 +84,13 @@ namespace Serenity.Extensions.Texts {
export const SaveChangesButton: string;
export const SaveSuccessMessage: string;
export const SourceLanguage: string;
export const SourceTargetLanguageSame: string;
export const SourceText: string;
export const TargetLanguage: string;
export const TargetLanguageRequired: string;
export const TargetText: string;
export const TranslateAllText: string;
export const TranslateTextDisabled: string;
export const UserTranslated: string;
}
}
Expand All @@ -101,7 +105,10 @@ namespace Serenity.Extensions.Texts {
export const PasswordStrengthRequireUppercase: string;
}

Serenity.Extensions['Texts'] = proxyTexts(Texts, '', {
}

export const Texts: typeof texts = proxyTexts({}, '',
{
Db: {
Common: {
UserPreference: {}
Expand All @@ -121,7 +128,4 @@ namespace Serenity.Extensions.Texts {
Translation: {}
},
Validation: {}
}) as any;
}

export const Texts = Serenity.Extensions.Texts;
}) as any;
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
namespace Serenity.Extensions;

[DefaultSectionKey(SectionKey)]
public class DefaultTranslationOptions : IOptions<DefaultTranslationOptions>
public class BaseTranslationOptions
{
public const string SectionKey = "Translation";
public bool Enabled { get; set; }
public bool UseStructuredOutput { get; set; }
public int ParallelRequest { get; set; }
public int BatchSize { get; set; }
public DefaultTranslationOptions Value => this;
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace Serenity.Extensions;

public class TranslateTextResponse : ServiceRequest
public class TranslateTextResponse : ServiceResponse
{
public List<TranslateTextOutput> Translations { get; set; }
}
Expand Down
1 change: 1 addition & 0 deletions src/Serenity.Extensions/Modules/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export * from "./ServerTypes/Extensions";
export * from "./ServerTypes/Reporting";
export * from "./ServerTypes/Texts";
export * from "./BulkActions/BasicProgressDialog";
export * from "./BulkActions/BulkServiceAction";
export * from "./ExportImport/ExcelExportHelper";
Expand Down
126 changes: 109 additions & 17 deletions src/Serenity.Extensions/dist/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,23 @@ export interface ResetPasswordResponse extends ServiceResponse {
export interface SendResetPasswordResponse extends ServiceResponse {
DemoLink?: string;
}
export interface TranslateTextInput {
TextKey?: string;
TargetLanguageID?: string;
SourceText?: string;
}
export interface TranslateTextOutput {
TextKey?: string;
TargetLanguageID?: string;
TranslatedText?: string;
}
export interface TranslateTextRequest extends ServiceRequest {
SourceLanguageID?: string;
Inputs?: TranslateTextInput[];
}
export interface TranslateTextResponse extends ServiceResponse {
Translations?: TranslateTextOutput[];
}
export interface TranslationItem {
Key?: string;
SourceText?: string;
Expand Down Expand Up @@ -134,23 +151,6 @@ export declare namespace UserPreferenceService {
readonly Retrieve: "Extensions/UserPreference/Retrieve";
};
}
export interface TranslateTextInput {
TextKey?: string;
TargetLanguageID?: string;
SourceText?: string;
}
export interface TranslateTextRequest extends ServiceRequest {
SourceLanguageID?: string;
Inputs?: TranslateTextInput[];
}
export interface TranslateTextOutput {
TextKey?: string;
TargetLanguageID?: string;
TranslatedText?: string;
}
export interface TranslateTextResponse extends ServiceResponse {
Outputs?: TranslateTextOutput[];
}
export interface ReportRetrieveResult extends ServiceResponse {
ReportKey?: string;
Title?: string;
Expand All @@ -159,6 +159,98 @@ export interface ReportRetrieveResult extends ServiceResponse {
IsDataOnlyReport?: boolean;
IsExternalReport?: boolean;
}
declare namespace texts {
namespace Db {
namespace Common {
namespace UserPreference {
const Name: string;
const PreferenceType: string;
const UserId: string;
const UserPreferenceId: string;
const Value: string;
}
}
}
namespace Forms {
namespace Membership {
namespace ChangePassword {
const ElevatedActions: string;
const FormTitle: string;
const PasswordNotSet: string;
const SetPassword: string;
const SetPasswordButton: string;
const SetPasswordInfo: string;
const SetPasswordSuccess: string;
const SubmitButton: string;
const Success: string;
}
namespace ForgotPassword {
const FormInfo: string;
const FormTitle: string;
const SubmitButton: string;
const SuccessMessage: string;
}
namespace ResetPassword {
const EmailSubject: string;
const FormTitle: string;
const SubmitButton: string;
const Success: string;
}
}
}
namespace Site {
namespace BasicProgressDialog {
const CancelTitle: string;
const PleaseWait: string;
}
namespace BulkServiceAction {
const AllHadErrorsFormat: string;
const AllSuccessFormat: string;
const ConfirmationFormat: string;
const ErrorCount: string;
const NothingToProcess: string;
const SomeHadErrorsFormat: string;
const SuccessCount: string;
}
namespace Dialogs {
const PendingChangesConfirmation: string;
const PendingChangesUnloadWarning: string;
}
namespace Translation {
const Assembly: string;
const CopyFailMessage: string;
const CopySourceTranslations: string;
const CopySuccessMessage: string;
const CopyTargetTranslations: string;
const CustomText: string;
const EntityPlural: string;
const HasTranslation: string;
const Key: string;
const OverrideConfirmation: string;
const SaveChangesButton: string;
const SaveSuccessMessage: string;
const SourceLanguage: string;
const SourceTargetLanguageSame: string;
const SourceText: string;
const TargetLanguage: string;
const TargetLanguageRequired: string;
const TargetText: string;
const TranslateAllText: string;
const TranslateTextDisabled: string;
const UserTranslated: string;
}
}
namespace Validation {
const InvalidResetToken: string;
const MinRequiredPasswordLength: string;
const PasswordConfirmMismatch: string;
const PasswordStrengthRequireDigit: string;
const PasswordStrengthRequireLowercase: string;
const PasswordStrengthRequireNonAlphanumeric: string;
const PasswordStrengthRequireUppercase: string;
}
}
export declare const Texts: typeof texts;
export declare class BasicProgressDialog<P = {}> extends BaseDialog<P> {
constructor(props?: WidgetProps<P>);
cancelled: boolean;
Expand Down
5 changes: 5 additions & 0 deletions src/Serenity.Extensions/texts/ExtensionsTexts.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,15 @@ public static class Translation
public static readonly LocalText SaveChangesButton = "Save Changes";
public static readonly LocalText SaveSuccessMessage = "User translations in target language are saved to {0}";
public static readonly LocalText SourceLanguage = "Source Language";
public static readonly LocalText SourceTargetLanguageSame = "Source and target languages should be different!";
public static readonly LocalText SourceText = "Effective Translation in Source Language";
public static readonly LocalText TargetLanguage = "Target Language";
public static readonly LocalText TargetLanguageRequired = "Please select target language!";
public static readonly LocalText TargetText = "Effective Translation in Target Language";
public static readonly LocalText TranslateAllText = "AI Translate All";
public static readonly LocalText TranslateTextDisabled = "Auto translation is disabled!";
public static readonly LocalText UserTranslated = "User Translated";

}
}

Expand Down

0 comments on commit 1a23302

Please sign in to comment.