@@ -633,11 +633,34 @@ Style rules allow you to customize your translations using a managed, shared lis
633633of rules for style, formatting, and more. Multiple style rules can be stored with
634634your account, each with a user-specified name and a uniquely-assigned ID.
635635
636- #### Creating and managing style rules
636+ #### Creating a style rule
637637
638- Currently style rules must be created and managed in the DeepL UI via
639- https://www.deepl.com/en/custom-rules . Full CRUD functionality via the APIs will
640- come shortly.
638+ Use ` createStyleRule() ` to create a new style rule with a name and language.
639+ You can optionally pass configured rules and custom instructions:
640+
641+ ``` php
642+ // Create a basic style rule
643+ $styleRule = $deeplClient->createStyleRule('My Style', 'en');
644+ echo "Created: {$styleRule->name} ({$styleRule->styleId})\n";
645+
646+ // Create with configured rules and custom instructions
647+ $styleRule = $deeplClient->createStyleRule(
648+ 'Formal English',
649+ 'en',
650+ ['style_and_tone' => ['formal_informal' => 'formal']],
651+ [['label' => 'Formality', 'prompt' => 'Always use formal language']]
652+ );
653+ ```
654+
655+ #### Getting a style rule
656+
657+ Use ` getStyleRule() ` to retrieve a single style rule by its ID or a
658+ ` StyleRuleInfo ` object:
659+
660+ ``` php
661+ $styleRule = $deeplClient->getStyleRule('dca2e053-8ae5-45e6-a0d2-881156e7f4e4');
662+ echo "{$styleRule->name} ({$styleRule->language})\n";
663+ ```
641664
642665#### Listing all style rules
643666
@@ -663,6 +686,60 @@ foreach ($styleRulesDetailed as $rule) {
663686}
664687```
665688
689+ #### Updating a style rule
690+
691+ Use ` updateStyleRuleName() ` to rename a style rule, and
692+ ` updateStyleRuleConfiguredRules() ` to replace the configured rules:
693+
694+ ``` php
695+ // Update the name
696+ $updated = $deeplClient->updateStyleRuleName($styleRule, 'New Name');
697+
698+ // Replace configured rules
699+ $updated = $deeplClient->updateStyleRuleConfiguredRules($styleRule, [
700+ 'style_and_tone' => ['formal_informal' => 'informal'],
701+ 'punctuation' => ['oxford_comma' => 'always'],
702+ ]);
703+ ```
704+
705+ #### Deleting a style rule
706+
707+ Use ` deleteStyleRule() ` to delete a style rule:
708+
709+ ``` php
710+ $deeplClient->deleteStyleRule($styleRule);
711+ ```
712+
713+ #### Managing custom instructions
714+
715+ Custom instructions allow you to add free-text prompts to a style rule. Use the
716+ custom instruction methods to create, get, update, and delete them:
717+
718+ ``` php
719+ // Create a custom instruction
720+ $instruction = $deeplClient->createStyleRuleCustomInstruction(
721+ $styleRule,
722+ 'Formality',
723+ 'Always use formal language',
724+ 'de' // optional source language
725+ );
726+ echo "Instruction ID: {$instruction->id}\n";
727+
728+ // Get a custom instruction
729+ $instruction = $deeplClient->getStyleRuleCustomInstruction($styleRule, $instruction->id);
730+
731+ // Update a custom instruction
732+ $updated = $deeplClient->updateStyleRuleCustomInstruction(
733+ $styleRule,
734+ $instruction->id,
735+ 'Updated Label',
736+ 'Use very formal language'
737+ );
738+
739+ // Delete a custom instruction
740+ $deeplClient->deleteStyleRuleCustomInstruction($styleRule, $instruction->id);
741+ ```
742+
666743#### Using a stored style rule
667744
668745You can use a stored style rule for text translation by setting the ` style_id `
0 commit comments