fn get_initial_state(&self, locale: &str) -> Result<TemplateState, ClientError> {
        let state_str = match WindowVariable::new_str("__PERSEUS_INITIAL_STATE") {
            WindowVariable::Some(state_str) => state_str,
            WindowVariable::Malformed | WindowVariable::None => {
                return Err(ClientInvariantError::InitialState.into())
            }
        };

        // If there was an error, it's specially injected with this prefix before error
        // page data
        if state_str.starts_with("error-") {
            // We strip the prefix and escape any tab/newline control characters (inserted
            // by `fmterr`). Any others are user-inserted, and this is documented.
            let err_page_data_str = state_str
                .strip_prefix("error-")
                .unwrap()
                .replace('\n', "\\n")
                .replace('\t', "\\t");
            // There will be error page data encoded after `error-`
            let err_page_data = match serde_json::from_str::<ServerErrorData>(&err_page_data_str) {
                Ok(data) => data,
                Err(err) => {
                    return Err(ClientInvariantError::InitialStateError { source: err }.into())
                }
            };
            // This will be sent back to the handler for proper rendering, the only
            // difference is that the user won't get a flash to an error page,
            // they will have started with an error
            let err = ClientError::ServerError {
                status: err_page_data.status,
                message: err_page_data.msg,
            };
            // We do this in here so that even incremental pages that appear fine to the
            // router, but that actually error out, trigger this checkpoint
            if err_page_data.status == 404 {
                checkpoint("not_found");
            }
            // In some nice cases, the server will have been able to figure out the locale,
            // which we should have (this is one of those things that most sites
            // don't bother with because it's not easy to build, and *this* is
            // where a framework really shines). If we do have it, it'll be
            // in the `__PERSEUS_TRANSLATIONS` variable. If that's there, then the error
            // provided will be localized, so, if we can't get the translator,
            // we'll prefer to return an internal error that comes up as a popup
            // (since we don't want to replace a localized error with an unlocalized one).
            // If we know we have something unlocalized, just replace it with whatever we
            // have now.
            //
            // Note: in the case of a server-given error, we'll only not have translations
            // if there was an internal error (since `/this-page-does-not-exist`
            // would be a locale redirection).
            match WindowVariable::new_str("__PERSEUS_TRANSLATIONS") {
                // We have translations! Any errors in resolving them fully will be propagated.
                // We guarantee that this locale is supported based on the invariants of this
                // function.
                WindowVariable::Some(translations_str) => self
                    .translations_manager
                    .set_translator_for_translations_str(locale, &translations_str)?,
                // This would be extremely odd...but it's still a problem that could happen (and
                // there *should* be a localized error that the user can see)
                WindowVariable::Malformed => return Err(ClientInvariantError::Translations.into()),
                // There was probably an internal server error
                WindowVariable::None => (),
            };

            Err(err)
        } else {
            match TemplateState::from_str(&state_str) {
                Ok(state) => Ok(state),
                // An actual error means the state was provided, but it was malformed, so we'll
                // render an error page
                Err(_) => Err(ClientInvariantError::InitialState.into()),
            }
        }
    }
Gets the initial state injected by the server, if there was any. This is
used to differentiate initial loads from subsequent ones, which have
different log chains to prevent double-trips (a common SPA problem).

# Panics
This will panic if the given locale is not supported.
packages/perseus/src/reactor/initial_load.rs