you will need localized version of the month names and as second challenge you will need to execute the above code, when language is switched.
Step 1: The month names are stored in constants. Per default the constants contain only the English version of the names. You will find the constants in the Browser window:
Step 2: Depending on whether you want the full or abbreviated month names to be displayed, create variants of the respective constants within one of your own (!) unit. For example, to create a variant of the constant January, I dragged the constant from the Browser window to the Composer window with the Application unit while pressing the keys CTRL, SHIFT and ALT (see also Create new constant variant):
Step 3: When you select the just created variant, you can edit its content for each language individually in the Inspector window. For example, the language Spanish if such exists in your project:
Step 4: Repeat the above steps for all other month constants.
Step 5: If you want the above code (the code form your question) to be executed when the language is changed, you have to place the code within the ReInit method. This method is automatically executed, when the language is changed. See also: React programmatically to language selection.