File tree Expand file tree Collapse file tree
autoclear-chatgpt-history/utils
chatgpt-auto-refresh/utils Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11'''
22Script: translate-en-messages.py
3- Version: 2026.1.18
3+ Version: 2026.1.26
44Description: Translate msg's from en/messages.json to [[output_langs]/messages.json]
55Author: Adam Lui
66Homepage: https://github.com/adamlui/python-utils
2424terminal_width = os .get_terminal_size ()[0 ]
2525def print_trunc (msg , end = '\n ' ):
2626 truncated_lines = [
27- line if len (line ) < terminal_width else line [:terminal_width - 4 ] + '...' for line in msg .splitlines () ]
27+ line if len (line ) < terminal_width else line [:terminal_width - 4 ] + '...' for line in msg .splitlines () ]
2828 print ('\n ' .join (truncated_lines ), end = end )
2929def overwrite_print (msg ) : stdout .write ('\r ' + msg .ljust (terminal_width )[:terminal_width ])
3030
@@ -128,7 +128,7 @@ def overwrite_print(msg) : stdout.write('\r' + msg.ljust(terminal_width)[:termin
128128 formatted_msg = json .dumps (message_data , ensure_ascii = False ) \
129129 .replace ('{' , '{ ' ).replace ('}' , ' }' ) # add spacing
130130 formatted_msgs += ( f' "{ key } ": { formatted_msg } '
131- + ( ',\n ' if idx < len (translated_msgs ) - 1 else '\n ' )) # terminate line
131+ + ( ',\n ' if idx < len (translated_msgs ) - 1 else '\n ' )) # terminate line
132132 formatted_msgs += '}'
133133 with open (msgs_path , 'w' , encoding = 'utf-8' ) as output_file : output_file .write (formatted_msgs + '\n ' )
134134
Original file line number Diff line number Diff line change 11'''
22Script: translate-en-messages.py
3- Version: 2026.1.18
3+ Version: 2026.1.26
44Description: Translate msg's from en/messages.json to [[output_langs]/messages.json]
55Author: Adam Lui
66Homepage: https://github.com/adamlui/python-utils
2424terminal_width = os .get_terminal_size ()[0 ]
2525def print_trunc (msg , end = '\n ' ):
2626 truncated_lines = [
27- line if len (line ) < terminal_width else line [:terminal_width - 4 ] + '...' for line in msg .splitlines () ]
27+ line if len (line ) < terminal_width else line [:terminal_width - 4 ] + '...' for line in msg .splitlines () ]
2828 print ('\n ' .join (truncated_lines ), end = end )
2929def overwrite_print (msg ) : stdout .write ('\r ' + msg .ljust (terminal_width )[:terminal_width ])
3030
@@ -128,7 +128,7 @@ def overwrite_print(msg) : stdout.write('\r' + msg.ljust(terminal_width)[:termin
128128 formatted_msg = json .dumps (message_data , ensure_ascii = False ) \
129129 .replace ('{' , '{ ' ).replace ('}' , ' }' ) # add spacing
130130 formatted_msgs += ( f' "{ key } ": { formatted_msg } '
131- + ( ',\n ' if idx < len (translated_msgs ) - 1 else '\n ' )) # terminate line
131+ + ( ',\n ' if idx < len (translated_msgs ) - 1 else '\n ' )) # terminate line
132132 formatted_msgs += '}'
133133 with open (msgs_path , 'w' , encoding = 'utf-8' ) as output_file : output_file .write (formatted_msgs + '\n ' )
134134
Original file line number Diff line number Diff line change 11'''
22Script: translate-en-messages.py
3- Version: 2026.1.18
3+ Version: 2026.1.26
44Description: Translate msg's from en/messages.json to [[output_langs]/messages.json]
55Author: Adam Lui
66Homepage: https://github.com/adamlui/python-utils
2424terminal_width = os .get_terminal_size ()[0 ]
2525def print_trunc (msg , end = '\n ' ):
2626 truncated_lines = [
27- line if len (line ) < terminal_width else line [:terminal_width - 4 ] + '...' for line in msg .splitlines () ]
27+ line if len (line ) < terminal_width else line [:terminal_width - 4 ] + '...' for line in msg .splitlines () ]
2828 print ('\n ' .join (truncated_lines ), end = end )
2929def overwrite_print (msg ) : stdout .write ('\r ' + msg .ljust (terminal_width )[:terminal_width ])
3030
@@ -128,7 +128,7 @@ def overwrite_print(msg) : stdout.write('\r' + msg.ljust(terminal_width)[:termin
128128 formatted_msg = json .dumps (message_data , ensure_ascii = False ) \
129129 .replace ('{' , '{ ' ).replace ('}' , ' }' ) # add spacing
130130 formatted_msgs += ( f' "{ key } ": { formatted_msg } '
131- + ( ',\n ' if idx < len (translated_msgs ) - 1 else '\n ' )) # terminate line
131+ + ( ',\n ' if idx < len (translated_msgs ) - 1 else '\n ' )) # terminate line
132132 formatted_msgs += '}'
133133 with open (msgs_path , 'w' , encoding = 'utf-8' ) as output_file : output_file .write (formatted_msgs + '\n ' )
134134
Original file line number Diff line number Diff line change 11'''
22Script: translate-en-messages.py
3- Version: 2026.1.18
3+ Version: 2026.1.26
44Description: Translate msg's from en/messages.json to [[output_langs]/messages.json]
55Author: Adam Lui
66Homepage: https://github.com/adamlui/python-utils
2424terminal_width = os .get_terminal_size ()[0 ]
2525def print_trunc (msg , end = '\n ' ):
2626 truncated_lines = [
27- line if len (line ) < terminal_width else line [:terminal_width - 4 ] + '...' for line in msg .splitlines () ]
27+ line if len (line ) < terminal_width else line [:terminal_width - 4 ] + '...' for line in msg .splitlines () ]
2828 print ('\n ' .join (truncated_lines ), end = end )
2929def overwrite_print (msg ) : stdout .write ('\r ' + msg .ljust (terminal_width )[:terminal_width ])
3030
@@ -128,7 +128,7 @@ def overwrite_print(msg) : stdout.write('\r' + msg.ljust(terminal_width)[:termin
128128 formatted_msg = json .dumps (message_data , ensure_ascii = False ) \
129129 .replace ('{' , '{ ' ).replace ('}' , ' }' ) # add spacing
130130 formatted_msgs += ( f' "{ key } ": { formatted_msg } '
131- + ( ',\n ' if idx < len (translated_msgs ) - 1 else '\n ' )) # terminate line
131+ + ( ',\n ' if idx < len (translated_msgs ) - 1 else '\n ' )) # terminate line
132132 formatted_msgs += '}'
133133 with open (msgs_path , 'w' , encoding = 'utf-8' ) as output_file : output_file .write (formatted_msgs + '\n ' )
134134
Original file line number Diff line number Diff line change 11'''
22Script: translate-en-messages.py
3- Version: 2026.1.18
3+ Version: 2026.1.26
44Description: Translate msg's from en/messages.json to [[output_langs]/messages.json]
55Author: Adam Lui
66Homepage: https://github.com/adamlui/python-utils
2424terminal_width = os .get_terminal_size ()[0 ]
2525def print_trunc (msg , end = '\n ' ):
2626 truncated_lines = [
27- line if len (line ) < terminal_width else line [:terminal_width - 4 ] + '...' for line in msg .splitlines () ]
27+ line if len (line ) < terminal_width else line [:terminal_width - 4 ] + '...' for line in msg .splitlines () ]
2828 print ('\n ' .join (truncated_lines ), end = end )
2929def overwrite_print (msg ) : stdout .write ('\r ' + msg .ljust (terminal_width )[:terminal_width ])
3030
@@ -128,7 +128,7 @@ def overwrite_print(msg) : stdout.write('\r' + msg.ljust(terminal_width)[:termin
128128 formatted_msg = json .dumps (message_data , ensure_ascii = False ) \
129129 .replace ('{' , '{ ' ).replace ('}' , ' }' ) # add spacing
130130 formatted_msgs += ( f' "{ key } ": { formatted_msg } '
131- + ( ',\n ' if idx < len (translated_msgs ) - 1 else '\n ' )) # terminate line
131+ + ( ',\n ' if idx < len (translated_msgs ) - 1 else '\n ' )) # terminate line
132132 formatted_msgs += '}'
133133 with open (msgs_path , 'w' , encoding = 'utf-8' ) as output_file : output_file .write (formatted_msgs + '\n ' )
134134
Original file line number Diff line number Diff line change 11'''
22Script: translate-en-messages.py
3- Version: 2026.1.18
3+ Version: 2026.1.26
44Description: Translate msg's from en/messages.json to [[output_langs]/messages.json]
55Author: Adam Lui
66Homepage: https://github.com/adamlui/python-utils
2424terminal_width = os .get_terminal_size ()[0 ]
2525def print_trunc (msg , end = '\n ' ):
2626 truncated_lines = [
27- line if len (line ) < terminal_width else line [:terminal_width - 4 ] + '...' for line in msg .splitlines () ]
27+ line if len (line ) < terminal_width else line [:terminal_width - 4 ] + '...' for line in msg .splitlines () ]
2828 print ('\n ' .join (truncated_lines ), end = end )
2929def overwrite_print (msg ) : stdout .write ('\r ' + msg .ljust (terminal_width )[:terminal_width ])
3030
@@ -128,7 +128,7 @@ def overwrite_print(msg) : stdout.write('\r' + msg.ljust(terminal_width)[:termin
128128 formatted_msg = json .dumps (message_data , ensure_ascii = False ) \
129129 .replace ('{' , '{ ' ).replace ('}' , ' }' ) # add spacing
130130 formatted_msgs += ( f' "{ key } ": { formatted_msg } '
131- + ( ',\n ' if idx < len (translated_msgs ) - 1 else '\n ' )) # terminate line
131+ + ( ',\n ' if idx < len (translated_msgs ) - 1 else '\n ' )) # terminate line
132132 formatted_msgs += '}'
133133 with open (msgs_path , 'w' , encoding = 'utf-8' ) as output_file : output_file .write (formatted_msgs + '\n ' )
134134
Original file line number Diff line number Diff line change 11'''
22Script: translate-en-messages.py
3- Version: 2026.1.18
3+ Version: 2026.1.26
44Description: Translate msg's from en/messages.json to [[output_langs]/messages.json]
55Author: Adam Lui
66Homepage: https://github.com/adamlui/python-utils
2424terminal_width = os .get_terminal_size ()[0 ]
2525def print_trunc (msg , end = '\n ' ):
2626 truncated_lines = [
27- line if len (line ) < terminal_width else line [:terminal_width - 4 ] + '...' for line in msg .splitlines () ]
27+ line if len (line ) < terminal_width else line [:terminal_width - 4 ] + '...' for line in msg .splitlines () ]
2828 print ('\n ' .join (truncated_lines ), end = end )
2929def overwrite_print (msg ) : stdout .write ('\r ' + msg .ljust (terminal_width )[:terminal_width ])
3030
@@ -128,7 +128,7 @@ def overwrite_print(msg) : stdout.write('\r' + msg.ljust(terminal_width)[:termin
128128 formatted_msg = json .dumps (message_data , ensure_ascii = False ) \
129129 .replace ('{' , '{ ' ).replace ('}' , ' }' ) # add spacing
130130 formatted_msgs += ( f' "{ key } ": { formatted_msg } '
131- + ( ',\n ' if idx < len (translated_msgs ) - 1 else '\n ' )) # terminate line
131+ + ( ',\n ' if idx < len (translated_msgs ) - 1 else '\n ' )) # terminate line
132132 formatted_msgs += '}'
133133 with open (msgs_path , 'w' , encoding = 'utf-8' ) as output_file : output_file .write (formatted_msgs + '\n ' )
134134
You can’t perform that action at this time.
0 commit comments