Skip to content

TranslationServiceに翻訳対象の情報を引数で渡せるようにする #36

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

Conversation

tsuna-can-se
Copy link
Owner

この Pull request で実施したこと

CoreSettingsクラスを削除しました。
TranlationServiceに情報を引数で渡せるようにしました。

この Pull request では実施していないこと

なし。

Issues や Discussions 、関連する Web サイトなどへのリンク

なし。

`AITranslator.cs` で `sourceLanguage` を nullable に変更し、プロンプト生成のための `CreatePrompt` メソッドを追加しました。
`Program.cs` では設定の取得方法を変更し、`ParameterNotSetException` を導入しました。
`ITranslator.cs` の `TranslateAsync` メソッドも `sourceLanguage` を nullable に更新。
`Messages` リソースに無効な文化名のメッセージを追加し、`ServiceCollectionExtensions.cs` では設定バインディングを削除しました。
`TranslationService.cs` ではコンストラクタから `CoreSettings` のオプションを削除し、直接パラメータを受け取るように変更。
`CoreSettings.cs` ではプロパティの直接使用を促進し、`ConvertTo` メソッドを統合。
テストコードも新しいメソッドシグネチャに合わせて更新し、`ParameterNotSetException` クラスを新たに追加しました。
`outputDirectoryPath`の取得方法を変更し、値が設定されていない場合には空の文字列が代入されるようにしました。これにより、常に有効な文字列が保証されます。
DumpCoreSettings というローカライズされた文字列が `Messages.Designer.cs` と `Messages.resx` から削除されました。この変更により、"CoreSetting variables: {Variables}" という文字列はもはや利用できなくなります。`DirectoryCreated` と `InvalidXmlString` のリソースは引き続き残っています。
`outputDirectoryPath`の取得方法を変更し、デフォルト値として空の文字列を指定するようにしました。これにより、`OutputDirectoryPath`が設定されていない場合に、より明示的に空の文字列が返されるようになります。
`AISettings`の設定方法を明確にし、`TranslationService`の`ExecuteAsync`メソッドに必要な引数を追加しました。`CoreSettings`に関する記述を削除し、`AddTranslatorServices`の呼び出しを簡略化しました。これにより、AIを利用した翻訳機能の利用が促進されます。
@tsuna-can-se tsuna-can-se added this to the v0.1.0-Beta1 milestone May 26, 2025
@tsuna-can-se tsuna-can-se self-assigned this May 26, 2025
@Copilot Copilot AI review requested due to automatic review settings May 26, 2025 15:00
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR refactors the translation functionality by removing the CoreSettings dependency and enabling the TranslationService to receive translation parameters as arguments. It updates the service registration, test cases, CLI configuration, and AI translation logic accordingly.

  • Removed CoreSettings and updated TranslationService to accept explicit parameters.
  • Updated tests and CLI to reflect the new API signature.
  • Adjusted DI registration and documentation for the new configuration approach.

Reviewed Changes

Copilot reviewed 14 out of 16 changed files in this pull request and generated no comments.

Show a summary per file
File Description
tests/Test.TsunaCan.XmlDocumentationTranslator.Core/TranslationServiceTest.cs Updated test to pass translation parameters and adjusted log count expectation.
tests/Test.TsunaCan.XmlDocumentationTranslator.Core/CoreSettingsTest.cs Removed obsolete tests for CoreSettings.
src/TsunaCan.XmlDocumentationTranslator.Core/TranslationService.cs Changed ExecuteAsync API to accept parameters; removed CoreSettings usage.
src/TsunaCan.XmlDocumentationTranslator.Core/ServiceCollectionExtensions.cs Updated DI registration by removing CoreSettings configuration.
src/TsunaCan.XmlDocumentationTranslator.Core/README.md Updated documentation with the new API usage.
src/TsunaCan.XmlDocumentationTranslator.Cli/Program.cs Modified to retrieve configuration values and call the new ExecuteAsync signature.
src/TsunaCan.XmlDocumentationTranslator.Cli/ParameterNotSetException.cs Introduced exception for missing required parameters.
src/TsunaCan.XmlDocumentationTranslator.AI/AITranslator.cs Updated translation prompt creation to accommodate nullable source language.
src/TsunaCan.XmlDocumentationTranslator.AI/README.md Updated documentation to reflect changes in configuration requirements.
Files not reviewed (2)
  • src/TsunaCan.XmlDocumentationTranslator.Cli/Resources/Messages.Designer.cs: Language not supported
  • src/TsunaCan.XmlDocumentationTranslator.Core/Resources/Messages.Designer.cs: Language not supported
Comments suppressed due to low confidence (1)

src/TsunaCan.XmlDocumentationTranslator.Core/TranslationService.cs:46

  • The current list initialization using empty square brackets may not be valid for a List. Consider replacing it with 'new List()' for proper instantiation.
List<string> outputFiles = [];

@tsuna-can-se tsuna-can-se merged commit 3994f53 into main May 26, 2025
5 checks passed
@tsuna-can-se tsuna-can-se deleted the feature/TranslationServiceに翻訳対象の情報を引数で渡せるようにする branch May 26, 2025 15:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant