For example, with example.com/en/apple/12/article/11/23, in
arg(0) returns "apple," as I expect; in
hook_boot() it returns
en which is language prefix of English.
That is because
hook_boot() is invoked too early in the bootstrap process, which means:
- Not all the modules are loaded, including the Locale module that is the one that alter the path, and the reason why
arg(0)returns "apple" in your example, when called in
- The language has not been set; it is initialized during the
hook_boot()is invoked during the
- The call to drupal_path_initialize(), which alters
$_GET['q'] = drupal_get_normal_path($_GET['q']);is done during the
DRUPAL_BOOTSTRAP_FULLphase, which is the last bootstrap phase.
hook_init() is invoked as last step done in the
DRUPAL_BOOTSTRAP_FULL phase, which means all modules are loaded, the language has been set, and
drupal_path_initialize() has been already called.
As side note,
hook_boot() has been removed from Drupal 8; if you are using it, you will need to change your code. Using
hook_init() is a possible alternative, since it is still used in Drupal 8.