Skip to content

better error msg when smiley directory not writable#7713

Merged
live627 merged 5 commits intoSimpleMachines:release-2.1from
jeffythedragonslayer:smiley_dir
Jun 15, 2023
Merged

better error msg when smiley directory not writable#7713
live627 merged 5 commits intoSimpleMachines:release-2.1from
jeffythedragonslayer:smiley_dir

Conversation

@jeffythedragonslayer
Copy link
Contributor

@jeffythedragonslayer jeffythedragonslayer commented Mar 20, 2023

fix #7617

@jdarwood007
Copy link
Member

Needs to use language strings for translation. Better fix would be to use sprintf to handle subsitions.
Also adds a line return at the end of the file.

@jeffythedragonslayer
Copy link
Contributor Author

Do you mean the way I have written the line right now adds a line return but it shouldn't, or it doesn't add a line return but should? By "substitutions" are you saying the sprintf call should lookup the correct translation?

@live627
Copy link
Contributor

live627 commented Mar 20, 2023 via email

@jdarwood007
Copy link
Member

sprintf is used to write the translatable string, but you leave a place holder for the set name. So it can make sense which set this refers to.

@jeffythedragonslayer
Copy link
Contributor Author

Sorry, I don't know where the trailing newline is.

@DiegoAndresCortes
Copy link
Member

At the end of the file. Happens commonly if you edited the file on the browser or similar.

@jeffythedragonslayer
Copy link
Contributor Author

Oh I see now, you mean the newline at the end of ManageSmiley.php I thought you meant a newline in the log file.

@jeffythedragonslayer
Copy link
Contributor Author

I now mention which smiley set. If anyone knows of any good string localization examples in the code base I can learn from please let me know.

Copy link
Contributor

@live627 live627 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I have been checking this code out, and a detailed message is not needed. I can discard my write-up showing you where to put the language entry.

Co-authored-by: John Rayes <live627@gmail.com>
@jeffythedragonslayer
Copy link
Contributor Author

That's too bad - that writeup would've really come in handy the next time I work on localization.

@Sesquipedalian
Copy link
Member

Localization in SMF is pretty easy. Just put any user-facing strings into the $txt array in SMF's language files, and then refer to the string in your code via the $txt variable.

For example, if you wanted to educate the user about how delicious cucumbers soaked in brine are, you could do the following:

  1. Add this to the appropriate language file:
$txt['pickle'] = 'Pickles are yummy!';
  1. At the relevant place in the code, do something like this:
$some_var_that_will_be_shown_to_the_user = $txt['pickle'];

If your changes to the code introduce the global $txt variable into a function that previously didn't use it, you will also need to declare it as a global variable at the top of the function, like this:

global $txt;

@jeffythedragonslayer
Copy link
Contributor Author

Ooh excellent example @Sesquipedalian. I think this could make a good tutorial on the scripting help section of the forum, btw.

@live627 live627 merged commit d964e91 into SimpleMachines:release-2.1 Jun 15, 2023
@sbulen sbulen added this to the 2.1.5 milestone Aug 22, 2023
@live627 live627 added Localization Language & internationalization and removed Language labels Mar 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Localization Language & internationalization

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Incorrect error message + error log entry when trying to upload smiley to folder with missing permissions

6 participants