Use an extension function for initializing

`$wgMessagesDirs` is fixed, `$wgExtensionFunctions` does not need to be declared global because it is used in the global context.