diff --git a/src/Hook/StringPluralFormHooks.php b/src/Hook/StringPluralFormHooks.php
new file mode 100644
index 0000000..f8e721b
--- /dev/null
+++ b/src/Hook/StringPluralFormHooks.php
@@ -0,0 +1,35 @@
+<?php
+
+namespace Drupal\string_plural_form\Hook;
+
+use Drupal\Core\Render\Element;
+use Drupal\Core\Hook\Attribute\Hook;
+/**
+ * Hook implementations for string_plural_form.
+ */
+class StringPluralFormHooks
+{
+    /**
+     * Implements hook_form_FORM_ID_alter().
+     */
+    #[Hook('form_locale_translate_edit_form_alter')]
+    public static function formLocaleTranslateEditFormAlter(&$form, $form_state)
+    {
+        if (isset($form['strings'])) {
+            $config = \Drupal::config('string_plural_form.settings')->get('rules');
+            $lang_code = $form["langcode"]["#value"];
+            if (empty($config[$lang_code])) {
+                return;
+            }
+            $instance = \Drupal::service('plugin.manager.string_plural_form')->createInstance($config[$lang_code]);
+            foreach (\Drupal\Core\Render\Element::children($form['strings']) as $key) {
+                $item =& $form['strings'][$key];
+                if (isset($item['translations'][1])) {
+                    foreach (\Drupal\Core\Render\Element::children($item['translations']) as $index) {
+                        $form['strings'][$key]['translations'][$index]['#title'] = $instance->getIndexLabel($index);
+                    }
+                }
+            }
+        }
+    }
+}
diff --git a/string_plural_form.info.yml b/string_plural_form.info.yml
index b4b13b7..05b36d4 100644
--- a/string_plural_form.info.yml
+++ b/string_plural_form.info.yml
@@ -2,6 +2,6 @@ name: 'String Plural Form'
 type: module
 description: 'Handle Plural rules for translatable strings'
 package: Locale
-core_version_requirement: ^10.2 || ^11
+core_version_requirement: ^10.2 || ^11 || ^12
 dependencies:
   - locale
diff --git a/string_plural_form.module b/string_plural_form.module
index 726f0a9..ec62d5e 100644
--- a/string_plural_form.module
+++ b/string_plural_form.module
@@ -4,28 +4,14 @@
  * @file
  * String Plural Form Module file.
  */
-
+use Drupal\Core\Hook\Attribute\LegacyHook;
+use Drupal\string_plural_form\Hook\StringPluralFormHooks;
 use Drupal\Core\Render\Element;
 
 /**
  * Implements hook_form_FORM_ID_alter().
  */
+#[LegacyHook]
 function string_plural_form_form_locale_translate_edit_form_alter(&$form, $form_state) {
-  if (isset($form['strings'])) {
-    $config = \Drupal::config('string_plural_form.settings')
-      ->get('rules');
-    $lang_code = $form["langcode"]["#value"];
-    if (empty($config[$lang_code])) {
-      return;
-    }
-    $instance = \Drupal::service('plugin.manager.string_plural_form')->createInstance($config[$lang_code]);
-    foreach (Element::children($form['strings']) as $key) {
-      $item = &$form['strings'][$key];
-      if (isset($item['translations'][1])) {
-        foreach (Element::children($item['translations']) as $index) {
-          $form['strings'][$key]['translations'][$index]['#title'] = $instance->getIndexLabel($index);
-        }
-      }
-    }
-  }
+  \Drupal::service(StringPluralFormHooks::class)->formLocaleTranslateEditFormAlter($form, $form_state);
 }
diff --git a/string_plural_form.services.yml b/string_plural_form.services.yml
index 6e6e425..2b9209b 100644
--- a/string_plural_form.services.yml
+++ b/string_plural_form.services.yml
@@ -2,3 +2,7 @@ services:
   plugin.manager.string_plural_form:
     class: Drupal\string_plural_form\StringPluralFormManager
     parent: default_plugin_manager
+
+  Drupal\string_plural_form\Hook\StringPluralFormHooks:
+    class: Drupal\string_plural_form\Hook\StringPluralFormHooks
+    autowire: true
