Hooks and updating fields in multi language sites

I have a working hook, that populates a field β€˜date’ with the title, which is a date-string in the format yyyy-mm-dd and replaces the title with a formatted date:

kirby()->hook('panel.page.create', function ($page) {
  if ($page->intendedTemplate() === 'date') {
    $format = l::get('date-title-format', 'Market in {city} on %d. %B %Y'); // expectedly not working
    $format = str::template($format, [
      'city' => $page->parent()->title()->value()
    ]);

    $title = $page->date($format, 'title');
    $uri = str::slug($title);
    
    if (! $page->parent()->find($uri)) {
      $page->update([
        'date' => $page->title()->value(),
        'title' => $title
      ]);
      $page->move($uri);
    }
  }
});

However l::get does not work – and I understand why. But I was wondering how I would change the format for each language? How do hooks work in multilanguage situations?

I found out that page->update() takes a language code as a second argument and I simply called it twice for each language:

<?php
kirby()->hook('panel.page.create', function ($page) {
  if ($page->intendedTemplate() === 'date') {
    $format_de = str::template('Markt in {city} am %d. %B %Y', [
      'city' => $page->parent()->title()->value()
    ]);

    $format_en = str::template('Market in {city} on %d. %B %Y', [
      'city' => $page->parent()->title()->value()
    ]);

    $title_de = $page->date($format_de, 'title');
    $title_en = $page->date($format_en, 'title');
    $uri = str::slug($title_de);

    if (! $page->parent()->find($uri)) {
      $page->update([
        'date' => $page->title()->value(),
        'title' => $title_en,
        'status'
      ], 'en');
      $page->update([
        'date' => $page->title()->value(),
        'title' => $title_de
      ], 'de');
      $page->move($uri);
      $page->hide();
    }
  }
});
?>

I’d rather have the format-string in the language file, but it works for now.