How i can check variable for non-empty in selector?

How i can check random $variable for non-empty/existing?
What about if variable will not passed from application?

For example, random .ftl file:

that_string = 
{    $username ->
          [what i need to pass there?] Hello! ### - if $username is empty
        *[other] Hello, { $username }!
}.

I need to check $username for existance inside FTL syntax.
How it’s possible?

Fluent selection is not meant to replace code logic.
You should check if the user name is present and decide on what l10n message to use to localize it.
You should have two messages hello-not-logged-in and hello-logged-in and the latter should take a variable.

See https://github.com/projectfluent/fluent/wiki/Good-Practices-for-Developers for more details.

You can handle this kind of situation in a few different ways depending on how your template is structured. Usually, the idea is to check whether the variable is present and then display a fallback text if it isn’t. Fluent provides some basic patterns for handling missing or empty values, so you don’t always need to rely on complex logic. You can use a simple default approach or let the message choose the correct variant when the variable isn’t passed. This way your template stays clean, and it still works even if the application doesn’t provide the variable.